| 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.full_emitter; | 5 part of dart2js.js_emitter.full_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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 'typeInformation': typeInformationAccess, | 104 'typeInformation': typeInformationAccess, |
| 105 'globalFunctions': globalFunctionsAccess, | 105 'globalFunctions': globalFunctionsAccess, |
| 106 'enabledInvokeOn': backend.hasInvokeOnSupport, | 106 'enabledInvokeOn': backend.hasInvokeOnSupport, |
| 107 'interceptedNames': interceptedNamesAccess, | 107 'interceptedNames': interceptedNamesAccess, |
| 108 'interceptedNamesSet': emitter.generateInterceptedNamesSet(), | 108 'interceptedNamesSet': emitter.generateInterceptedNamesSet(), |
| 109 'notInCspMode': !compiler.options.useContentSecurityPolicy, | 109 'notInCspMode': !compiler.options.useContentSecurityPolicy, |
| 110 'inCspMode': compiler.options.useContentSecurityPolicy, | 110 'inCspMode': compiler.options.useContentSecurityPolicy, |
| 111 'deferredAction': namer.deferredAction, | 111 'deferredAction': namer.deferredAction, |
| 112 'hasIsolateSupport': program.hasIsolateSupport, | 112 'hasIsolateSupport': program.hasIsolateSupport, |
| 113 'fieldNamesProperty': js.string(Emitter.FIELD_NAMES_PROPERTY_NAME), | 113 'fieldNamesProperty': js.string(Emitter.FIELD_NAMES_PROPERTY_NAME), |
| 114 'hasIncrementalSupport': compiler.options.hasIncrementalSupport, | |
| 115 'incrementalHelper': namer.accessIncrementalHelper, | |
| 116 'createNewIsolateFunction': createNewIsolateFunctionAccess, | 114 'createNewIsolateFunction': createNewIsolateFunctionAccess, |
| 117 'isolateName': namer.isolateName, | 115 'isolateName': namer.isolateName, |
| 118 'classIdExtractor': classIdExtractorAccess, | 116 'classIdExtractor': classIdExtractorAccess, |
| 119 'classFieldsExtractor': classFieldsExtractorAccess, | 117 'classFieldsExtractor': classFieldsExtractorAccess, |
| 120 'instanceFromClassId': instanceFromClassIdAccess, | 118 'instanceFromClassId': instanceFromClassIdAccess, |
| 121 'initializeEmptyInstance': initializeEmptyInstanceAccess, | 119 'initializeEmptyInstance': initializeEmptyInstanceAccess, |
| 122 'allClasses': allClassesAccess, | 120 'allClasses': allClassesAccess, |
| 123 'debugFastObjects': DEBUG_FAST_OBJECTS, | 121 'debugFastObjects': DEBUG_FAST_OBJECTS, |
| 124 'isTreeShakingDisabled': backend.isTreeShakingDisabled, | 122 'isTreeShakingDisabled': backend.isTreeShakingDisabled, |
| 125 'precompiled': precompiledAccess, | 123 'precompiled': precompiledAccess, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 247 } |
| 250 if (#hasIsolateSupport) { | 248 if (#hasIsolateSupport) { |
| 251 str += name + "." + #fieldNamesProperty + "=[" + fieldNames | 249 str += name + "." + #fieldNamesProperty + "=[" + fieldNames |
| 252 + "];\\n"; | 250 + "];\\n"; |
| 253 } | 251 } |
| 254 str += accessors.join(""); | 252 str += accessors.join(""); |
| 255 | 253 |
| 256 return str; | 254 return str; |
| 257 } | 255 } |
| 258 | 256 |
| 259 if (#hasIncrementalSupport) { | |
| 260 #incrementalHelper.defineClass = defineClass; | |
| 261 } | |
| 262 | |
| 263 if (#hasIsolateSupport) { | 257 if (#hasIsolateSupport) { |
| 264 #createNewIsolateFunction = function() { return new #isolateName(); }; | 258 #createNewIsolateFunction = function() { return new #isolateName(); }; |
| 265 | 259 |
| 266 #classIdExtractor = function(o) { return o.constructor.name; }; | 260 #classIdExtractor = function(o) { return o.constructor.name; }; |
| 267 | 261 |
| 268 #classFieldsExtractor = function(o) { | 262 #classFieldsExtractor = function(o) { |
| 269 var fieldNames = o.constructor.#fieldNamesProperty; | 263 var fieldNames = o.constructor.#fieldNamesProperty; |
| 270 if (!fieldNames) return []; // TODO(floitsch): do something else here. | 264 if (!fieldNames) return []; // TODO(floitsch): do something else here. |
| 271 var result = []; | 265 var result = []; |
| 272 result.length = fieldNames.length; | 266 result.length = fieldNames.length; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 305 } |
| 312 // Use a function for `true` here, as functions are stored in the | 306 // Use a function for `true` here, as functions are stored in the |
| 313 // hidden class and not as properties in the object. | 307 // hidden class and not as properties in the object. |
| 314 object[#operatorIsPrefix + constructor.name] = constructor; | 308 object[#operatorIsPrefix + constructor.name] = constructor; |
| 315 object.constructor = constructor; | 309 object.constructor = constructor; |
| 316 constructor.prototype = object; | 310 constructor.prototype = object; |
| 317 return object; | 311 return object; |
| 318 }; | 312 }; |
| 319 }(); | 313 }(); |
| 320 | 314 |
| 321 if (#hasIncrementalSupport) { | |
| 322 #incrementalHelper.inheritFrom = inheritFrom; | |
| 323 } | |
| 324 | |
| 325 // Class descriptions are collected in a JS object. | 315 // Class descriptions are collected in a JS object. |
| 326 // 'finishClasses' takes all collected descriptions and sets up | 316 // 'finishClasses' takes all collected descriptions and sets up |
| 327 // the prototype. | 317 // the prototype. |
| 328 // Once set up, the constructors prototype field satisfy: | 318 // Once set up, the constructors prototype field satisfy: |
| 329 // - it contains all (local) members. | 319 // - it contains all (local) members. |
| 330 // - its internal prototype (__proto__) points to the superclass' | 320 // - its internal prototype (__proto__) points to the superclass' |
| 331 // prototype field. | 321 // prototype field. |
| 332 // - the prototype's constructor field points to the JavaScript | 322 // - the prototype's constructor field points to the JavaScript |
| 333 // constructor. | 323 // constructor. |
| 334 // For engines where we have access to the '__proto__' we can manipulate | 324 // For engines where we have access to the '__proto__' we can manipulate |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 } | 745 } |
| 756 } | 746 } |
| 757 } | 747 } |
| 758 | 748 |
| 759 if (#enabledJsInterop) { | 749 if (#enabledJsInterop) { |
| 760 #jsInteropBoostrap | 750 #jsInteropBoostrap |
| 761 } | 751 } |
| 762 #tearOffCode; | 752 #tearOffCode; |
| 763 } | 753 } |
| 764 | 754 |
| 765 if (#hasIncrementalSupport) { | |
| 766 #incrementalHelper.addStubs = addStubs; | |
| 767 } | |
| 768 | |
| 769 var functionCounter = 0; | 755 var functionCounter = 0; |
| 770 if (!#libraries) #libraries = []; | 756 if (!#libraries) #libraries = []; |
| 771 if (!#mangledNames) #mangledNames = map(); | 757 if (!#mangledNames) #mangledNames = map(); |
| 772 if (!#mangledGlobalNames) #mangledGlobalNames = map(); | 758 if (!#mangledGlobalNames) #mangledGlobalNames = map(); |
| 773 if (!#statics) #statics = map(); | 759 if (!#statics) #statics = map(); |
| 774 if (!#typeInformation) #typeInformation = map(); | 760 if (!#typeInformation) #typeInformation = map(); |
| 775 if (!#globalFunctions) #globalFunctions = map(); | 761 if (!#globalFunctions) #globalFunctions = map(); |
| 776 if (#enabledInvokeOn) | 762 if (#enabledInvokeOn) |
| 777 if (!#interceptedNames) #interceptedNames = #interceptedNamesSet; | 763 if (!#interceptedNames) #interceptedNames = #interceptedNamesSet; |
| 778 var libraries = #libraries; | 764 var libraries = #libraries; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 (function() { | 841 (function() { |
| 856 var result = $array[$index]; | 842 var result = $array[$index]; |
| 857 if ($check) { | 843 if ($check) { |
| 858 throw new Error( | 844 throw new Error( |
| 859 name + ": expected value of type \'$type\' at index " + ($index) + | 845 name + ": expected value of type \'$type\' at index " + ($index) + |
| 860 " but got " + (typeof result)); | 846 " but got " + (typeof result)); |
| 861 } | 847 } |
| 862 return result; | 848 return result; |
| 863 })()'''; | 849 })()'''; |
| 864 } | 850 } |
| OLD | NEW |