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

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

Issue 1088943006: implement tear offs (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 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; 1 var _js_helper;
2 (function(exports) { 2 (function(exports) {
3 'use strict'; 3 'use strict';
4 class NoSideEffects extends core.Object { 4 class NoSideEffects extends core.Object {
5 NoSideEffects() { 5 NoSideEffects() {
6 } 6 }
7 } 7 }
8 class NoThrows extends core.Object { 8 class NoThrows extends core.Object {
9 NoThrows() { 9 NoThrows() {
10 } 10 }
(...skipping 2614 matching lines...) Expand 10 before | Expand all | Expand 10 after
2625 } 2625 }
2626 let signatureFunction = null; 2626 let signatureFunction = null;
2627 if (typeof functionType == "number") { 2627 if (typeof functionType == "number") {
2628 let metadata = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names .METADATA); 2628 let metadata = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names .METADATA);
2629 signatureFunction = function(s) { 2629 signatureFunction = function(s) {
2630 return function() { 2630 return function() {
2631 return metadata[s]; 2631 return metadata[s];
2632 }; 2632 };
2633 }(functionType); 2633 }(functionType);
2634 } else if (!dart.notNull(isStatic) && typeof functionType == "function") { 2634 } else if (!dart.notNull(isStatic) && typeof functionType == "function") {
2635 let getReceiver = isIntercepted ? _foreign_helper.RAW_DART_FUNCTION_REF( BoundClosure.receiverOf) : _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.se lfOf); 2635 let getReceiver = isIntercepted ? _foreign_helper.RAW_DART_FUNCTION_REF( dart.bind(BoundClosure, 'receiverOf')) : _foreign_helper.RAW_DART_FUNCTION_REF(d art.bind(BoundClosure, 'selfOf'));
2636 signatureFunction = function(f, r) { 2636 signatureFunction = function(f, r) {
2637 return function() { 2637 return function() {
2638 return f.apply({$receiver: r(this)}, arguments$); 2638 return f.apply({$receiver: r(this)}, arguments$);
2639 }; 2639 };
2640 }(functionType, getReceiver); 2640 }(functionType, getReceiver);
2641 } else { 2641 } else {
2642 throw 'Error in reflectionInfo.'; 2642 throw 'Error in reflectionInfo.';
2643 } 2643 }
2644 prototype[_foreign_helper.JS_SIGNATURE_NAME()] = signatureFunction; 2644 prototype[_foreign_helper.JS_SIGNATURE_NAME()] = signatureFunction;
2645 prototype[callName] = trampoline; 2645 prototype[callName] = trampoline;
2646 for (let i = 1; dart.notNull(i) < dart.notNull(functions[core.$length]); i = dart.notNull(i) + 1) { 2646 for (let i = 1; dart.notNull(i) < dart.notNull(functions[core.$length]); i = dart.notNull(i) + 1) {
2647 let stub = functions[core.$get](i); 2647 let stub = functions[core.$get](i);
2648 let stubCallName = stub.$callName; 2648 let stubCallName = stub.$callName;
2649 if (stubCallName != null) { 2649 if (stubCallName != null) {
2650 prototype[stubCallName] = isStatic ? stub : Closure.forwardCallTo(rece iver, stub, isIntercepted); 2650 prototype[stubCallName] = isStatic ? stub : Closure.forwardCallTo(rece iver, stub, isIntercepted);
2651 } 2651 }
2652 } 2652 }
2653 prototype["call*"] = trampoline; 2653 prototype["call*"] = trampoline;
2654 return constructor; 2654 return constructor;
2655 } 2655 }
2656 static cspForwardCall(arity, isSuperCall, stubName, func) { 2656 static cspForwardCall(arity, isSuperCall, stubName, func) {
2657 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.selfOf); 2657 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(dart.bind(BoundClosure , 'selfOf'));
2658 if (isSuperCall) 2658 if (isSuperCall)
2659 arity = -1; 2659 arity = -1;
2660 switch (arity) { 2660 switch (arity) {
2661 case 0: 2661 case 0:
2662 { 2662 {
2663 return function(n, S) { 2663 return function(n, S) {
2664 return function() { 2664 return function() {
2665 return S(this)[n](); 2665 return S(this)[n]();
2666 }; 2666 };
2667 }(stubName, getSelf); 2667 }(stubName, getSelf);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2738 } 2738 }
2739 dart.assert(1 <= dart.notNull(arity) && dart.notNull(arity) < 27); 2739 dart.assert(1 <= dart.notNull(arity) && dart.notNull(arity) < 27);
2740 let arguments$ = "abcdefghijklmnopqrstuvwxyz".split("").splice(0, arity).j oin(","); 2740 let arguments$ = "abcdefghijklmnopqrstuvwxyz".split("").splice(0, arity).j oin(",");
2741 return new Function(`return function(${arguments$}){` + `return this.${Bou ndClosure.selfFieldName()}.${stubName}(${arguments$});` + `${(() => { 2741 return new Function(`return function(${arguments$}){` + `return this.${Bou ndClosure.selfFieldName()}.${stubName}(${arguments$});` + `${(() => {
2742 let x = Closure.functionCounter; 2742 let x = Closure.functionCounter;
2743 Closure.functionCounter = dart.notNull(x) + 1; 2743 Closure.functionCounter = dart.notNull(x) + 1;
2744 return x; 2744 return x;
2745 })()}` + '}')(); 2745 })()}` + '}')();
2746 } 2746 }
2747 static cspForwardInterceptedCall(arity, isSuperCall, name, func) { 2747 static cspForwardInterceptedCall(arity, isSuperCall, name, func) {
2748 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.selfOf); 2748 let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(dart.bind(BoundClosure , 'selfOf'));
2749 let getReceiver = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.recei verOf); 2749 let getReceiver = _foreign_helper.RAW_DART_FUNCTION_REF(dart.bind(BoundClo sure, 'receiverOf'));
2750 if (isSuperCall) 2750 if (isSuperCall)
2751 arity = -1; 2751 arity = -1;
2752 switch (arity) { 2752 switch (arity) {
2753 case 0: 2753 case 0:
2754 { 2754 {
2755 throw new RuntimeError('Intercepted function with no arguments.'); 2755 throw new RuntimeError('Intercepted function with no arguments.');
2756 } 2756 }
2757 case 1: 2757 case 1:
2758 { 2758 {
2759 return function(n, s, r) { 2759 return function(n, s, r) {
(...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after
4044 exports.jsonEncodeNative = jsonEncodeNative; 4044 exports.jsonEncodeNative = jsonEncodeNative;
4045 exports.getIsolateAffinityTag = getIsolateAffinityTag; 4045 exports.getIsolateAffinityTag = getIsolateAffinityTag;
4046 exports.LoadLibraryFunctionType = LoadLibraryFunctionType; 4046 exports.LoadLibraryFunctionType = LoadLibraryFunctionType;
4047 exports.DeferredLoadCallback = DeferredLoadCallback; 4047 exports.DeferredLoadCallback = DeferredLoadCallback;
4048 exports.loadDeferredLibrary = loadDeferredLibrary; 4048 exports.loadDeferredLibrary = loadDeferredLibrary;
4049 exports.MainError = MainError; 4049 exports.MainError = MainError;
4050 exports.missingMain = missingMain; 4050 exports.missingMain = missingMain;
4051 exports.badMain = badMain; 4051 exports.badMain = badMain;
4052 exports.mainHasTooManyParameters = mainHasTooManyParameters; 4052 exports.mainHasTooManyParameters = mainHasTooManyParameters;
4053 })(_js_helper || (_js_helper = {})); 4053 })(_js_helper || (_js_helper = {}));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698