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.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 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 const String setupProgramName ='setupProgram'; | 24 const String setupProgramName ='setupProgram'; |
| 25 // TODO(floitsch): make sure this property can't clash with anything. It's | 25 // TODO(floitsch): make sure this property can't clash with anything. It's |
| 26 // unlikely since it lives on types, but still. | 26 // unlikely since it lives on types, but still. |
| 27 const String typeNameProperty = r'builtin$cls'; | 27 const String typeNameProperty = r'builtin$cls'; |
| 28 | 28 |
| 29 jsAst.Statement buildSetupProgram(Program program, Compiler compiler, | 29 jsAst.Statement buildSetupProgram(Program program, Compiler compiler, |
| 30 JavaScriptBackend backend, | 30 JavaScriptBackend backend, |
| 31 Namer namer, | 31 Namer namer, |
| 32 Emitter emitter) { | 32 Emitter emitter) { |
| 33 | 33 |
|
sra1
2015/10/13 03:31:36
line?
| |
| 34 | |
| 34 jsAst.Expression typeInformationAccess = | 35 jsAst.Expression typeInformationAccess = |
| 35 emitter.generateEmbeddedGlobalAccess(embeddedNames.TYPE_INFORMATION); | 36 emitter.generateEmbeddedGlobalAccess(embeddedNames.TYPE_INFORMATION); |
| 36 jsAst.Expression globalFunctionsAccess = | 37 jsAst.Expression globalFunctionsAccess = |
| 37 emitter.generateEmbeddedGlobalAccess(embeddedNames.GLOBAL_FUNCTIONS); | 38 emitter.generateEmbeddedGlobalAccess(embeddedNames.GLOBAL_FUNCTIONS); |
| 38 jsAst.Expression staticsAccess = | 39 jsAst.Expression staticsAccess = |
| 39 emitter.generateEmbeddedGlobalAccess(embeddedNames.STATICS); | 40 emitter.generateEmbeddedGlobalAccess(embeddedNames.STATICS); |
| 40 jsAst.Expression interceptedNamesAccess = | 41 jsAst.Expression interceptedNamesAccess = |
| 41 emitter.generateEmbeddedGlobalAccess(embeddedNames.INTERCEPTED_NAMES); | 42 emitter.generateEmbeddedGlobalAccess(embeddedNames.INTERCEPTED_NAMES); |
| 42 jsAst.Expression mangledGlobalNamesAccess = | 43 jsAst.Expression mangledGlobalNamesAccess = |
| 43 emitter.generateEmbeddedGlobalAccess(embeddedNames.MANGLED_GLOBAL_NAMES); | 44 emitter.generateEmbeddedGlobalAccess(embeddedNames.MANGLED_GLOBAL_NAMES); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 'classFieldsExtractor': classFieldsExtractorAccess, | 121 'classFieldsExtractor': classFieldsExtractorAccess, |
| 121 'instanceFromClassId': instanceFromClassIdAccess, | 122 'instanceFromClassId': instanceFromClassIdAccess, |
| 122 'initializeEmptyInstance': initializeEmptyInstanceAccess, | 123 'initializeEmptyInstance': initializeEmptyInstanceAccess, |
| 123 'allClasses': allClassesAccess, | 124 'allClasses': allClassesAccess, |
| 124 'debugFastObjects': DEBUG_FAST_OBJECTS, | 125 'debugFastObjects': DEBUG_FAST_OBJECTS, |
| 125 'isTreeShakingDisabled': backend.isTreeShakingDisabled, | 126 'isTreeShakingDisabled': backend.isTreeShakingDisabled, |
| 126 'precompiled': precompiledAccess, | 127 'precompiled': precompiledAccess, |
| 127 'finishedClassesAccess': finishedClassesAccess, | 128 'finishedClassesAccess': finishedClassesAccess, |
| 128 'needsMixinSupport': emitter.needsMixinSupport, | 129 'needsMixinSupport': emitter.needsMixinSupport, |
| 129 'needsNativeSupport': program.needsNativeSupport, | 130 'needsNativeSupport': program.needsNativeSupport, |
| 131 'enabledJsInterop': backend.jsInteropAnalysis.enabledJsInterop, | |
| 132 'jsInteropBoostrap':backend.jsInteropAnalysis.buildJsInteropBootstrap(), | |
| 130 'isInterceptorClass': namer.operatorIs(backend.jsInterceptorClass), | 133 'isInterceptorClass': namer.operatorIs(backend.jsInterceptorClass), |
| 131 'isObject' : namer.operatorIs(compiler.objectClass), | 134 'isObject' : namer.operatorIs(compiler.objectClass), |
| 132 'specProperty': js.string(namer.nativeSpecProperty), | 135 'specProperty': js.string(namer.nativeSpecProperty), |
| 133 'trivialNsmHandlers': emitter.buildTrivialNsmHandlers(), | 136 'trivialNsmHandlers': emitter.buildTrivialNsmHandlers(), |
| 134 'hasRetainedMetadata': backend.hasRetainedMetadata, | 137 'hasRetainedMetadata': backend.hasRetainedMetadata, |
| 135 'types': typesAccess, | 138 'types': typesAccess, |
| 136 'objectClassName': js.quoteName( | 139 'objectClassName': js.quoteName( |
| 137 namer.runtimeTypeName(compiler.objectClass)), | 140 namer.runtimeTypeName(compiler.objectClass)), |
| 138 'needsStructuredMemberInfo': emitter.needsStructuredMemberInfo, | 141 'needsStructuredMemberInfo': emitter.needsStructuredMemberInfo, |
| 139 'usesMangledNames': | 142 'usesMangledNames': |
| 140 compiler.mirrorsLibrary != null || compiler.enabledFunctionApply, | 143 compiler.mirrorsLibrary != null || compiler.enabledFunctionApply, |
| 141 'tearOffCode': buildTearOffCode(backend), | 144 'tearOffCode': buildTearOffCode(backend), |
| 142 'nativeInfoHandler': nativeInfoHandler, | 145 'nativeInfoHandler': nativeInfoHandler, |
| 143 'operatorIsPrefix' : js.string(namer.operatorIsPrefix), | 146 'operatorIsPrefix' : js.string(namer.operatorIsPrefix), |
| 144 'deferredActionString': js.string(namer.deferredAction)}; | 147 'deferredActionString': js.string(namer.deferredAction)}; |
| 145 | |
| 146 String skeleton = ''' | 148 String skeleton = ''' |
| 147 function $setupProgramName(programData, typesOffset) { | 149 function $setupProgramName(programData, typesOffset) { |
| 148 "use strict"; | 150 "use strict"; |
| 149 if (#needsClassSupport) { | 151 if (#needsClassSupport) { |
| 150 | 152 |
| 151 function generateAccessor(fieldDescriptor, accessors, cls) { | 153 function generateAccessor(fieldDescriptor, accessors, cls) { |
| 152 var fieldInformation = fieldDescriptor.split("-"); | 154 var fieldInformation = fieldDescriptor.split("-"); |
| 153 var field = fieldInformation[0]; | 155 var field = fieldInformation[0]; |
| 154 var len = field.length; | 156 var len = field.length; |
| 155 var code = field.charCodeAt(len - 1); | 157 var code = field.charCodeAt(len - 1); |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 747 mangledNames[name] = reflectionName; | 749 mangledNames[name] = reflectionName; |
| 748 funcs[0].$reflectionNameField = reflectionName; | 750 funcs[0].$reflectionNameField = reflectionName; |
| 749 funcs[0].$metadataIndexField = unmangledNameIndex + 1; | 751 funcs[0].$metadataIndexField = unmangledNameIndex + 1; |
| 750 // The following line installs the [${JsGetName.CALL_CATCH_ALL}] | 752 // The following line installs the [${JsGetName.CALL_CATCH_ALL}] |
| 751 // property for closures. | 753 // property for closures. |
| 752 if (optionalParameterCount) prototype[unmangledName + "*"] = funcs[0]; | 754 if (optionalParameterCount) prototype[unmangledName + "*"] = funcs[0]; |
| 753 } | 755 } |
| 754 } | 756 } |
| 755 } | 757 } |
| 756 | 758 |
| 759 if (#enabledJsInterop) { | |
| 760 #jsInteropBoostrap | |
| 761 } | |
| 757 #tearOffCode; | 762 #tearOffCode; |
| 758 } | 763 } |
| 759 | 764 |
| 760 if (#hasIncrementalSupport) { | 765 if (#hasIncrementalSupport) { |
| 761 #incrementalHelper.addStubs = addStubs; | 766 #incrementalHelper.addStubs = addStubs; |
| 762 } | 767 } |
| 763 | 768 |
| 764 var functionCounter = 0; | 769 var functionCounter = 0; |
| 765 if (!#libraries) #libraries = []; | 770 if (!#libraries) #libraries = []; |
| 766 if (!#mangledNames) #mangledNames = map(); | 771 if (!#mangledNames) #mangledNames = map(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 848 (function() { | 853 (function() { |
| 849 var result = $array[$index]; | 854 var result = $array[$index]; |
| 850 if ($check) { | 855 if ($check) { |
| 851 throw new Error( | 856 throw new Error( |
| 852 name + ": expected value of type \'$type\' at index " + ($index) + | 857 name + ": expected value of type \'$type\' at index " + ($index) + |
| 853 " but got " + (typeof result)); | 858 " but got " + (typeof result)); |
| 854 } | 859 } |
| 855 return result; | 860 return result; |
| 856 })()'''; | 861 })()'''; |
| 857 } | 862 } |
| OLD | NEW |