| 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.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; |
| 11 const REQUIRED_PARAMETER_INDEX = 3; | 11 const REQUIRED_PARAMETER_INDEX = 3; |
| 12 const OPTIONAL_PARAMETER_INDEX = 4; | 12 const OPTIONAL_PARAMETER_INDEX = 4; |
| 13 const DEFAULT_ARGUMENTS_INDEX = 5; | 13 const DEFAULT_ARGUMENTS_INDEX = 5; |
| 14 | 14 |
| 15 const bool VALIDATE_DATA = false; | 15 const bool VALIDATE_DATA = false; |
| 16 | 16 |
| 17 const RANGE1_SIZE = RANGE1_LAST - RANGE1_FIRST + 1; | 17 const RANGE1_SIZE = RANGE1_LAST - RANGE1_FIRST + 1; |
| 18 const RANGE2_SIZE = RANGE2_LAST - RANGE2_FIRST + 1; | 18 const RANGE2_SIZE = RANGE2_LAST - RANGE2_FIRST + 1; |
| 19 const RANGE1_ADJUST = - (FIRST_FIELD_CODE - RANGE1_FIRST); | 19 const RANGE1_ADJUST = - (FIRST_FIELD_CODE - RANGE1_FIRST); |
| 20 const RANGE2_ADJUST = - (FIRST_FIELD_CODE + RANGE1_SIZE - RANGE2_FIRST); | 20 const RANGE2_ADJUST = - (FIRST_FIELD_CODE + RANGE1_SIZE - RANGE2_FIRST); |
| 21 const RANGE3_ADJUST = | 21 const RANGE3_ADJUST = |
| 22 - (FIRST_FIELD_CODE + RANGE1_SIZE + RANGE2_SIZE - RANGE3_FIRST); | 22 - (FIRST_FIELD_CODE + RANGE1_SIZE + RANGE2_SIZE - RANGE3_FIRST); |
| 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 OldEmitter emitter) { | 32 Emitter emitter) { |
| 33 | 33 |
| 34 jsAst.Expression typeInformationAccess = | 34 jsAst.Expression typeInformationAccess = |
| 35 emitter.generateEmbeddedGlobalAccess(embeddedNames.TYPE_INFORMATION); | 35 emitter.generateEmbeddedGlobalAccess(embeddedNames.TYPE_INFORMATION); |
| 36 jsAst.Expression globalFunctionsAccess = | 36 jsAst.Expression globalFunctionsAccess = |
| 37 emitter.generateEmbeddedGlobalAccess(embeddedNames.GLOBAL_FUNCTIONS); | 37 emitter.generateEmbeddedGlobalAccess(embeddedNames.GLOBAL_FUNCTIONS); |
| 38 jsAst.Expression staticsAccess = | 38 jsAst.Expression staticsAccess = |
| 39 emitter.generateEmbeddedGlobalAccess(embeddedNames.STATICS); | 39 emitter.generateEmbeddedGlobalAccess(embeddedNames.STATICS); |
| 40 jsAst.Expression interceptedNamesAccess = | 40 jsAst.Expression interceptedNamesAccess = |
| 41 emitter.generateEmbeddedGlobalAccess(embeddedNames.INTERCEPTED_NAMES); | 41 emitter.generateEmbeddedGlobalAccess(embeddedNames.INTERCEPTED_NAMES); |
| 42 jsAst.Expression mangledGlobalNamesAccess = | 42 jsAst.Expression mangledGlobalNamesAccess = |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 'statics': staticsAccess, | 104 'statics': staticsAccess, |
| 105 'typeInformation': typeInformationAccess, | 105 'typeInformation': typeInformationAccess, |
| 106 'globalFunctions': globalFunctionsAccess, | 106 'globalFunctions': globalFunctionsAccess, |
| 107 'enabledInvokeOn': compiler.enabledInvokeOn, | 107 'enabledInvokeOn': compiler.enabledInvokeOn, |
| 108 'interceptedNames': interceptedNamesAccess, | 108 'interceptedNames': interceptedNamesAccess, |
| 109 'interceptedNamesSet': emitter.generateInterceptedNamesSet(), | 109 'interceptedNamesSet': emitter.generateInterceptedNamesSet(), |
| 110 'notInCspMode': !compiler.useContentSecurityPolicy, | 110 'notInCspMode': !compiler.useContentSecurityPolicy, |
| 111 'inCspMode': compiler.useContentSecurityPolicy, | 111 'inCspMode': compiler.useContentSecurityPolicy, |
| 112 'deferredAction': namer.deferredAction, | 112 'deferredAction': namer.deferredAction, |
| 113 'hasIsolateSupport': program.hasIsolateSupport, | 113 'hasIsolateSupport': program.hasIsolateSupport, |
| 114 'fieldNamesProperty': js.string(OldEmitter.FIELD_NAMES_PROPERTY_NAME), | 114 'fieldNamesProperty': js.string(Emitter.FIELD_NAMES_PROPERTY_NAME), |
| 115 'hasIncrementalSupport': compiler.hasIncrementalSupport, | 115 'hasIncrementalSupport': compiler.hasIncrementalSupport, |
| 116 'incrementalHelper': namer.accessIncrementalHelper, | 116 'incrementalHelper': namer.accessIncrementalHelper, |
| 117 'createNewIsolateFunction': createNewIsolateFunctionAccess, | 117 'createNewIsolateFunction': createNewIsolateFunctionAccess, |
| 118 'isolateName': namer.isolateName, | 118 'isolateName': namer.isolateName, |
| 119 'classIdExtractor': classIdExtractorAccess, | 119 'classIdExtractor': classIdExtractorAccess, |
| 120 'classFieldsExtractor': classFieldsExtractorAccess, | 120 'classFieldsExtractor': classFieldsExtractorAccess, |
| 121 'instanceFromClassId': instanceFromClassIdAccess, | 121 'instanceFromClassId': instanceFromClassIdAccess, |
| 122 'initializeEmptyInstance': initializeEmptyInstanceAccess, | 122 'initializeEmptyInstance': initializeEmptyInstanceAccess, |
| 123 'allClasses': allClassesAccess, | 123 'allClasses': allClassesAccess, |
| 124 'debugFastObjects': DEBUG_FAST_OBJECTS, | 124 'debugFastObjects': DEBUG_FAST_OBJECTS, |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 (function() { | 846 (function() { |
| 847 var result = $array[$index]; | 847 var result = $array[$index]; |
| 848 if ($check) { | 848 if ($check) { |
| 849 throw new Error( | 849 throw new Error( |
| 850 name + ": expected value of type \'$type\' at index " + ($index) + | 850 name + ": expected value of type \'$type\' at index " + ($index) + |
| 851 " but got " + (typeof result)); | 851 " but got " + (typeof result)); |
| 852 } | 852 } |
| 853 return result; | 853 return result; |
| 854 })()'''; | 854 })()'''; |
| 855 } | 855 } |
| OLD | NEW |