Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library dart2js.new_js_emitter.model_emitter; | 5 library dart2js.new_js_emitter.model_emitter; |
| 6 | 6 |
| 7 import '../../constants/values.dart' show ConstantValue; | 7 import '../../constants/values.dart' show ConstantValue; |
| 8 import '../../dart2jslib.dart' show Compiler; | 8 import '../../dart2jslib.dart' show Compiler; |
| 9 import '../../dart_types.dart' show DartType; | 9 import '../../dart_types.dart' show DartType; |
| 10 import '../../elements/elements.dart' show ClassElement; | 10 import '../../elements/elements.dart' show ClassElement; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 | 121 |
| 122 'cyclicThrow': | 122 'cyclicThrow': |
| 123 backend.emitter.staticFunctionAccess(backend.getCyclicThrowHelper()), | 123 backend.emitter.staticFunctionAccess(backend.getCyclicThrowHelper()), |
| 124 'outputContainsConstantList': program.outputContainsConstantList, | 124 'outputContainsConstantList': program.outputContainsConstantList, |
| 125 'embeddedGlobals': emitEmbeddedGlobals(program), | 125 'embeddedGlobals': emitEmbeddedGlobals(program), |
| 126 'constants': emitConstants(fragment.constants), | 126 'constants': emitConstants(fragment.constants), |
| 127 'staticNonFinals': | 127 'staticNonFinals': |
| 128 emitStaticNonFinalFields(fragment.staticNonFinalFields), | 128 emitStaticNonFinalFields(fragment.staticNonFinalFields), |
| 129 'operatorIsPrefix': js.string(namer.operatorIsPrefix), | 129 'operatorIsPrefix': js.string(namer.operatorIsPrefix), |
| 130 'callName': js.string(namer.callNameField), | 130 'callName': js.string(namer.callNameField), |
| 131 'argCnt': js.string(namer.requiredParameterField), | |
|
floitsch
2015/02/20 09:07:01
use non-abbreviated names.
(I guess the same appl
herhut
2015/02/20 12:24:15
Done.
| |
| 132 'defArgValues': js.string(namer.defaultValuesField), | |
| 131 'eagerClasses': emitEagerClassInitializations(fragment.libraries), | 133 'eagerClasses': emitEagerClassInitializations(fragment.libraries), |
| 132 'invokeMain': fragment.invokeMain, | 134 'invokeMain': fragment.invokeMain, |
| 133 'code': code}; | 135 'code': code}; |
| 134 | 136 |
| 135 holes.addAll(nativeHoles(program)); | 137 holes.addAll(nativeHoles(program)); |
| 136 | 138 |
| 137 return js.js.statement(boilerplate, holes); | 139 return js.js.statement(boilerplate, holes); |
| 138 } | 140 } |
| 139 | 141 |
| 140 Map<String, dynamic> nativeHoles(Program program) { | 142 Map<String, dynamic> nativeHoles(Program program) { |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 824 }; | 826 }; |
| 825 } else { | 827 } else { |
| 826 // Parse the tear off information and generate compile handlers. | 828 // Parse the tear off information and generate compile handlers. |
| 827 // TODO(herhut): Share parser with instance methods. | 829 // TODO(herhut): Share parser with instance methods. |
| 828 function compileAllStubs() { | 830 function compileAllStubs() { |
| 829 var funs; | 831 var funs; |
| 830 var fun = compile(name, descriptor[0]); | 832 var fun = compile(name, descriptor[0]); |
| 831 fun[#callName] = descriptor[1]; | 833 fun[#callName] = descriptor[1]; |
| 832 holder[name] = fun; | 834 holder[name] = fun; |
| 833 funs = [fun]; | 835 funs = [fun]; |
| 834 for (var pos = 4; pos < descriptor.length; pos += 3) { | 836 // We iterate in blocks of 3 but have to stop before we reach the |
| 837 // (optional) two trailing items. To accomplish this, we only iterate | |
| 838 // until we reach length - 2. | |
| 839 for (var pos = 4; pos < descriptor.length - 2; pos += 3) { | |
| 835 var stubName = descriptor[pos]; | 840 var stubName = descriptor[pos]; |
| 836 fun = compile(stubName, descriptor[pos + 2]); | 841 fun = compile(stubName, descriptor[pos + 2]); |
| 837 fun[#callName] = descriptor[pos + 1]; | 842 fun[#callName] = descriptor[pos + 1]; |
| 838 holder[stubName] = fun; | 843 holder[stubName] = fun; |
| 839 funs.push(fun); | 844 funs.push(fun); |
| 840 } | 845 } |
| 841 if (descriptor[2] != null) { // tear-off name. | 846 if (descriptor[2] != null) { // tear-off name. |
| 842 // functions, reflectionInfo, isStatic, name, isIntercepted. | 847 // functions, reflectionInfo, isStatic, name, isIntercepted. |
| 843 holder[descriptor[2]] = | 848 holder[descriptor[2]] = |
| 844 tearOff(funs, descriptor[3], true, name, false); | 849 tearOff(funs, descriptor[3], true, name, false); |
| 845 } | 850 } |
| 851 if (descriptor[pos] != null) { | |
|
floitsch
2015/02/20 09:07:01
if (pos < descriptor.length) ?
herhut
2015/02/20 12:24:15
Why not :-)
| |
| 852 fun[#argCnt] = descriptor[pos]; | |
| 853 fun[#defArgValues] = descriptor[pos + 1]; | |
| 854 } | |
| 846 } | 855 } |
| 847 | 856 |
| 848 function setupCompileAllAndDelegateStub(name) { | 857 function setupCompileAllAndDelegateStub(name) { |
| 849 holder[name] = function() { | 858 holder[name] = function() { |
| 850 compileAllStubs(); | 859 compileAllStubs(); |
| 851 return holder[name].apply(this, arguments); | 860 return holder[name].apply(this, arguments); |
| 852 }; | 861 }; |
| 853 } | 862 } |
| 854 | 863 |
| 855 setupCompileAllAndDelegateStub(name); | 864 setupCompileAllAndDelegateStub(name); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1024 | 1033 |
| 1025 var end = Date.now(); | 1034 var end = Date.now(); |
| 1026 // print('Setup: ' + (end - start) + ' ms.'); | 1035 // print('Setup: ' + (end - start) + ' ms.'); |
| 1027 | 1036 |
| 1028 #invokeMain; // Start main. | 1037 #invokeMain; // Start main. |
| 1029 | 1038 |
| 1030 }(Date.now(), #code) | 1039 }(Date.now(), #code) |
| 1031 }"""; | 1040 }"""; |
| 1032 | 1041 |
| 1033 } | 1042 } |
| OLD | NEW |