| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 String reflectableField = namer.reflectableField; | 74 String reflectableField = namer.reflectableField; |
| 75 String reflectionInfoField = namer.reflectionInfoField; | 75 String reflectionInfoField = namer.reflectionInfoField; |
| 76 String reflectionNameField = namer.reflectionNameField; | 76 String reflectionNameField = namer.reflectionNameField; |
| 77 String metadataIndexField = namer.metadataIndexField; | 77 String metadataIndexField = namer.metadataIndexField; |
| 78 String defaultValuesField = namer.defaultValuesField; | 78 String defaultValuesField = namer.defaultValuesField; |
| 79 String methodsWithOptionalArgumentsField = | 79 String methodsWithOptionalArgumentsField = |
| 80 namer.methodsWithOptionalArgumentsField; | 80 namer.methodsWithOptionalArgumentsField; |
| 81 String unmangledNameIndex = backend.mustRetainMetadata | 81 String unmangledNameIndex = backend.mustRetainMetadata |
| 82 ? ' 3 * optionalParameterCount + 2 * requiredParameterCount + 3' | 82 ? ' 3 * optionalParameterCount + 2 * requiredParameterCount + 3' |
| 83 : ' 2 * optionalParameterCount + requiredParameterCount + 3'; | 83 : ' 2 * optionalParameterCount + requiredParameterCount + 3'; |
| 84 String receiverParamName = compiler.enableMinification ? "r" : "receiver"; | 84 String receiverParamName = compiler.options.enableMinification |
| 85 String valueParamName = compiler.enableMinification ? "v" : "value"; | 85 ? "r" : "receiver"; |
| 86 String space = compiler.enableMinification ? "" : " "; | 86 String valueParamName = compiler.options.enableMinification ? "v" : "value"; |
| 87 String space = compiler.options.enableMinification ? "" : " "; |
| 87 String _ = space; | 88 String _ = space; |
| 88 | 89 |
| 89 String specProperty = '"${namer.nativeSpecProperty}"'; // "%" | 90 String specProperty = '"${namer.nativeSpecProperty}"'; // "%" |
| 90 jsAst.Expression nativeInfoAccess = js('prototype[$specProperty]', []); | 91 jsAst.Expression nativeInfoAccess = js('prototype[$specProperty]', []); |
| 91 jsAst.Expression constructorAccess = js('constructor', []); | 92 jsAst.Expression constructorAccess = js('constructor', []); |
| 92 Function subclassReadGenerator = | 93 Function subclassReadGenerator = |
| 93 (jsAst.Expression subclass) => js('allClasses[#]', subclass); | 94 (jsAst.Expression subclass) => js('allClasses[#]', subclass); |
| 94 jsAst.Statement nativeInfoHandler = emitter. | 95 jsAst.Statement nativeInfoHandler = emitter. |
| 95 buildNativeInfoHandler(nativeInfoAccess, constructorAccess, | 96 buildNativeInfoHandler(nativeInfoAccess, constructorAccess, |
| 96 subclassReadGenerator, interceptorsByTagAccess, | 97 subclassReadGenerator, interceptorsByTagAccess, |
| 97 leafTagsAccess); | 98 leafTagsAccess); |
| 98 | 99 |
| 99 Map<String, dynamic> holes = | 100 Map<String, dynamic> holes = |
| 100 {'needsClassSupport': emitter.needsClassSupport, | 101 {'needsClassSupport': emitter.needsClassSupport, |
| 101 'libraries': librariesAccess, | 102 'libraries': librariesAccess, |
| 102 'mangledNames': mangledNamesAccess, | 103 'mangledNames': mangledNamesAccess, |
| 103 'mangledGlobalNames': mangledGlobalNamesAccess, | 104 'mangledGlobalNames': mangledGlobalNamesAccess, |
| 104 'statics': staticsAccess, | 105 'statics': staticsAccess, |
| 105 'staticsPropertyName': namer.staticsPropertyName, | 106 'staticsPropertyName': namer.staticsPropertyName, |
| 106 'staticsPropertyNameString': js.quoteName(namer.staticsPropertyName), | 107 'staticsPropertyNameString': js.quoteName(namer.staticsPropertyName), |
| 107 'typeInformation': typeInformationAccess, | 108 'typeInformation': typeInformationAccess, |
| 108 'globalFunctions': globalFunctionsAccess, | 109 'globalFunctions': globalFunctionsAccess, |
| 109 'enabledInvokeOn': compiler.enabledInvokeOn, | 110 'enabledInvokeOn': compiler.enabledInvokeOn, |
| 110 'interceptedNames': interceptedNamesAccess, | 111 'interceptedNames': interceptedNamesAccess, |
| 111 'interceptedNamesSet': emitter.generateInterceptedNamesSet(), | 112 'interceptedNamesSet': emitter.generateInterceptedNamesSet(), |
| 112 'notInCspMode': !compiler.useContentSecurityPolicy, | 113 'notInCspMode': !compiler.options.useContentSecurityPolicy, |
| 113 'inCspMode': compiler.useContentSecurityPolicy, | 114 'inCspMode': compiler.options.useContentSecurityPolicy, |
| 114 'deferredAction': namer.deferredAction, | 115 'deferredAction': namer.deferredAction, |
| 115 'hasIsolateSupport': program.hasIsolateSupport, | 116 'hasIsolateSupport': program.hasIsolateSupport, |
| 116 'fieldNamesProperty': js.string(Emitter.FIELD_NAMES_PROPERTY_NAME), | 117 'fieldNamesProperty': js.string(Emitter.FIELD_NAMES_PROPERTY_NAME), |
| 117 'hasIncrementalSupport': compiler.hasIncrementalSupport, | 118 'hasIncrementalSupport': compiler.options.hasIncrementalSupport, |
| 118 'incrementalHelper': namer.accessIncrementalHelper, | 119 'incrementalHelper': namer.accessIncrementalHelper, |
| 119 'createNewIsolateFunction': createNewIsolateFunctionAccess, | 120 'createNewIsolateFunction': createNewIsolateFunctionAccess, |
| 120 'isolateName': namer.isolateName, | 121 'isolateName': namer.isolateName, |
| 121 'classIdExtractor': classIdExtractorAccess, | 122 'classIdExtractor': classIdExtractorAccess, |
| 122 'classFieldsExtractor': classFieldsExtractorAccess, | 123 'classFieldsExtractor': classFieldsExtractorAccess, |
| 123 'instanceFromClassId': instanceFromClassIdAccess, | 124 'instanceFromClassId': instanceFromClassIdAccess, |
| 124 'initializeEmptyInstance': initializeEmptyInstanceAccess, | 125 'initializeEmptyInstance': initializeEmptyInstanceAccess, |
| 125 'allClasses': allClassesAccess, | 126 'allClasses': allClassesAccess, |
| 126 'debugFastObjects': DEBUG_FAST_OBJECTS, | 127 'debugFastObjects': DEBUG_FAST_OBJECTS, |
| 127 'isTreeShakingDisabled': backend.isTreeShakingDisabled, | 128 'isTreeShakingDisabled': backend.isTreeShakingDisabled, |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 (function() { | 855 (function() { |
| 855 var result = $array[$index]; | 856 var result = $array[$index]; |
| 856 if ($check) { | 857 if ($check) { |
| 857 throw new Error( | 858 throw new Error( |
| 858 name + ": expected value of type \'$type\' at index " + ($index) + | 859 name + ": expected value of type \'$type\' at index " + ($index) + |
| 859 " but got " + (typeof result)); | 860 " but got " + (typeof result)); |
| 860 } | 861 } |
| 861 return result; | 862 return result; |
| 862 })()'''; | 863 })()'''; |
| 863 } | 864 } |
| OLD | NEW |