Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: lib/runtime/dart/_js_helper.js

Issue 1142293002: Use dart.tearoff helper at tearoff sites (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Clean up conditional Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 var _js_helper = dart.defineLibrary(_js_helper, {}); 1 var _js_helper = dart.defineLibrary(_js_helper, {});
2 var core = dart.import(core); 2 var core = dart.import(core);
3 var collection = dart.import(collection); 3 var collection = dart.import(collection);
4 var _internal = dart.import(_internal); 4 var _internal = dart.import(_internal);
5 var _foreign_helper = dart.import(_foreign_helper); 5 var _foreign_helper = dart.import(_foreign_helper);
6 var _js_embedded_names = dart.import(_js_embedded_names); 6 var _js_embedded_names = dart.import(_js_embedded_names);
7 var _interceptors = dart.lazyImport(_interceptors); 7 var _interceptors = dart.lazyImport(_interceptors);
8 var _js_names = dart.import(_js_names); 8 var _js_names = dart.import(_js_names);
9 var async = dart.import(async); 9 var async = dart.import(async);
10 var _isolate_helper = dart.lazyImport(_isolate_helper); 10 var _isolate_helper = dart.lazyImport(_isolate_helper);
(...skipping 2826 matching lines...) Expand 10 before | Expand all | Expand 10 after
2837 } 2837 }
2838 let signatureFunction = null; 2838 let signatureFunction = null;
2839 if (typeof functionType == "number") { 2839 if (typeof functionType == "number") {
2840 let metadata = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names .METADATA); 2840 let metadata = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names .METADATA);
2841 signatureFunction = function(s) { 2841 signatureFunction = function(s) {
2842 return function() { 2842 return function() {
2843 return metadata[s]; 2843 return metadata[s];
2844 }; 2844 };
2845 }(functionType); 2845 }(functionType);
2846 } else if (!dart.notNull(isStatic) && typeof functionType == "function") { 2846 } else if (!dart.notNull(isStatic) && typeof functionType == "function") {
2847 let getReceiver = isIntercepted ? _foreign_helper.RAW_DART_FUNCTION_REF( dart.bind(BoundClosure, 'receiverOf')) : _foreign_helper.RAW_DART_FUNCTION_REF(d art.bind(BoundClosure, 'selfOf')); 2847 let getReceiver = isIntercepted ? _foreign_helper.RAW_DART_FUNCTION_REF( BoundClosure.receiverOf) : _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.se lfOf);
2848 signatureFunction = function(f, r) { 2848 signatureFunction = function(f, r) {
2849 return function() { 2849 return function() {
2850 return f.apply({$receiver: r(this)}, arguments$); 2850 return f.apply({$receiver: r(this)}, arguments$);
2851 }; 2851 };
2852 }(functionType, getReceiver); 2852 }(functionType, getReceiver);
2853 } else { 2853 } else {
2854 throw 'Error in reflectionInfo.'; 2854 throw 'Error in reflectionInfo.';
2855 } 2855 }
2856 prototype[_foreign_helper.JS_SIGNATURE_NAME()] = signatureFunction; 2856 prototype[_foreign_helper.JS_SIGNATURE_NAME()] = signatureFunction;
2857 prototype[callName] = trampoline; 2857 prototype[callName] = trampoline;
2858 for (let i = 1; dart.notNull(i) < dart.notNull(functions[core.$length]); i = dart.notNull(i) + 1) { 2858 for (let i = 1; dart.notNull(i) < dart.notNull(functions[core.$length]); i = dart.notNull(i) + 1) {
2859 let stub = functions[core.$get](i); 2859 let stub = functions[core.$get](i);
2860 let stubCallName = stub.$callName; 2860 let stubCallName = stub.$callName;
2861 if (stubCallName != null) { 2861 if (stubCallName != null) {
2862 prototype[stubCallName] = isStatic ? stub : Closure.forwardCallTo(rece iver, stub, isIntercepted); 2862 prototype[stubCallName] = isStatic ? stub : Closure.forwardCallTo(rece iver, stub, isIntercepted);
2863 } 2863 }
2864 } 2864 }
2865 prototype["call*"] = trampoline; 2865 prototype["call*"] = trampoline;
2866 return constructor; 2866 return constructor;
2867 } 2867 }
2868 static cspForwardCall(arity, isSuperCall, stubName, func) { 2868 static cspForwardCall(arity, isSuperCall, stubName, func) {
2869 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(dart.bind(BoundClosure , 'selfOf')); 2869 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.selfOf);
2870 if (isSuperCall) 2870 if (isSuperCall)
2871 arity = -1; 2871 arity = -1;
2872 switch (arity) { 2872 switch (arity) {
2873 case 0: 2873 case 0:
2874 { 2874 {
2875 return function(n, S) { 2875 return function(n, S) {
2876 return function() { 2876 return function() {
2877 return S(this)[n](); 2877 return S(this)[n]();
2878 }; 2878 };
2879 }(stubName, getSelf); 2879 }(stubName, getSelf);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2950 } 2950 }
2951 dart.assert(1 <= dart.notNull(arity) && dart.notNull(arity) < 27); 2951 dart.assert(1 <= dart.notNull(arity) && dart.notNull(arity) < 27);
2952 let arguments$ = "abcdefghijklmnopqrstuvwxyz".split("").splice(0, arity).j oin(","); 2952 let arguments$ = "abcdefghijklmnopqrstuvwxyz".split("").splice(0, arity).j oin(",");
2953 return new Function(`return function(${arguments$}){` + `return this.${Bou ndClosure.selfFieldName()}.${stubName}(${arguments$});` + `${(() => { 2953 return new Function(`return function(${arguments$}){` + `return this.${Bou ndClosure.selfFieldName()}.${stubName}(${arguments$});` + `${(() => {
2954 let x = Closure.functionCounter; 2954 let x = Closure.functionCounter;
2955 Closure.functionCounter = dart.notNull(x) + 1; 2955 Closure.functionCounter = dart.notNull(x) + 1;
2956 return x; 2956 return x;
2957 })()}` + '}')(); 2957 })()}` + '}')();
2958 } 2958 }
2959 static cspForwardInterceptedCall(arity, isSuperCall, name, func) { 2959 static cspForwardInterceptedCall(arity, isSuperCall, name, func) {
2960 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(dart.bind(BoundClosure , 'selfOf')); 2960 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.selfOf);
2961 let getReceiver = _foreign_helper.RAW_DART_FUNCTION_REF(dart.bind(BoundClo sure, 'receiverOf')); 2961 let getReceiver = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.recei verOf);
2962 if (isSuperCall) 2962 if (isSuperCall)
2963 arity = -1; 2963 arity = -1;
2964 switch (arity) { 2964 switch (arity) {
2965 case 0: 2965 case 0:
2966 { 2966 {
2967 throw new RuntimeError('Intercepted function with no arguments.'); 2967 throw new RuntimeError('Intercepted function with no arguments.');
2968 } 2968 }
2969 case 1: 2969 case 1:
2970 { 2970 {
2971 return function(n, s, r) { 2971 return function(n, s, r) {
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after
4357 exports.jsonEncodeNative = jsonEncodeNative; 4357 exports.jsonEncodeNative = jsonEncodeNative;
4358 exports.getIsolateAffinityTag = getIsolateAffinityTag; 4358 exports.getIsolateAffinityTag = getIsolateAffinityTag;
4359 exports.LoadLibraryFunctionType = LoadLibraryFunctionType; 4359 exports.LoadLibraryFunctionType = LoadLibraryFunctionType;
4360 exports.DeferredLoadCallback = DeferredLoadCallback; 4360 exports.DeferredLoadCallback = DeferredLoadCallback;
4361 exports.loadDeferredLibrary = loadDeferredLibrary; 4361 exports.loadDeferredLibrary = loadDeferredLibrary;
4362 exports.MainError = MainError; 4362 exports.MainError = MainError;
4363 exports.missingMain = missingMain; 4363 exports.missingMain = missingMain;
4364 exports.badMain = badMain; 4364 exports.badMain = badMain;
4365 exports.mainHasTooManyParameters = mainHasTooManyParameters; 4365 exports.mainHasTooManyParameters = mainHasTooManyParameters;
4366 })(_js_helper, core, collection, _internal, _foreign_helper, _js_embedded_names, _interceptors, _js_names, async, _isolate_helper); 4366 })(_js_helper, core, collection, _internal, _foreign_helper, _js_embedded_names, _interceptors, _js_names, async, _isolate_helper);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698