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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/js_helper.dart

Issue 895083002: Support tearoffs in the new emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
OLDNEW
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 library _js_helper; 5 library _js_helper;
6 6
7 import 'dart:_js_embedded_names' show 7 import 'dart:_js_embedded_names' show
8 GET_TYPE_FROM_NAME, 8 GET_TYPE_FROM_NAME,
9 GET_ISOLATE_TAG, 9 GET_ISOLATE_TAG,
10 INTERCEPTED_NAMES, 10 INTERCEPTED_NAMES,
(...skipping 1945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 * 1956 *
1957 * Further assumes that [reflectionInfo] is the end of the array created by 1957 * Further assumes that [reflectionInfo] is the end of the array created by
1958 * [dart2js.js_emitter.ContainerBuilder.addMemberMethod] starting with 1958 * [dart2js.js_emitter.ContainerBuilder.addMemberMethod] starting with
1959 * required parameter count. 1959 * required parameter count.
1960 * 1960 *
1961 * Caution: this function may be called when building constants. 1961 * Caution: this function may be called when building constants.
1962 * TODO(ahe): Don't call this function when building constants. 1962 * TODO(ahe): Don't call this function when building constants.
1963 */ 1963 */
1964 static fromTearOff(receiver, 1964 static fromTearOff(receiver,
1965 List functions, 1965 List functions,
1966 List reflectionInfo, 1966 var reflectionInfo,
floitsch 2015/02/03 19:40:02 Add comments to the function with the information
herhut 2015/02/03 21:18:58 Done.
1967 bool isStatic, 1967 bool isStatic,
1968 jsArguments, 1968 jsArguments,
1969 String propertyName) { 1969 String propertyName) {
1970 JS_EFFECT(() { 1970 JS_EFFECT(() {
1971 BoundClosure.receiverOf(JS('BoundClosure', 'void 0')); 1971 BoundClosure.receiverOf(JS('BoundClosure', 'void 0'));
1972 BoundClosure.selfOf(JS('BoundClosure', 'void 0')); 1972 BoundClosure.selfOf(JS('BoundClosure', 'void 0'));
1973 }); 1973 });
1974 // TODO(ahe): All the place below using \$ should be rewritten to go 1974 // TODO(ahe): All the place below using \$ should be rewritten to go
1975 // through the namer. 1975 // through the namer.
1976 var function = JS('', '#[#]', functions, 0); 1976 var function = JS('', '#[#]', functions, 0);
1977 String name = JS('String|Null', '#.\$stubName', function); 1977 String name = JS('String|Null', '#.\$stubName', function);
1978 String callName = JS('String|Null', '#.\$callName', function); 1978 String callName = JS('String|Null', '#.\$callName', function);
1979 1979
1980 JS('', '#.\$reflectionInfo = #', function, reflectionInfo); 1980 var functionType;
1981 ReflectionInfo info = new ReflectionInfo(function); 1981 if (reflectionInfo is List) {
1982 JS('', '#.\$reflectionInfo = #', function, reflectionInfo);
1983 ReflectionInfo info = new ReflectionInfo(function);
1984 functionType = info.functionType;
1985 } else {
1986 functionType = reflectionInfo;
1987 }
1982 1988
1983 var functionType = info.functionType;
1984 1989
1985 // function tmp() {}; 1990 // function tmp() {};
1986 // tmp.prototype = BC.prototype; 1991 // tmp.prototype = BC.prototype;
1987 // var proto = new tmp; 1992 // var proto = new tmp;
1988 // for each computed prototype property: 1993 // for each computed prototype property:
1989 // proto[property] = ...; 1994 // proto[property] = ...;
1990 // proto._init = BC; 1995 // proto._init = BC;
1991 // var dynClosureConstructor = 1996 // var dynClosureConstructor =
1992 // new Function('self', 'target', 'receiver', 'name', 1997 // new Function('self', 'target', 'receiver', 'name',
1993 // 'this._init(self, target, receiver, name)'); 1998 // 'this._init(self, target, receiver, name)');
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 /// Called from implicit method getter (aka tear-off). 2320 /// Called from implicit method getter (aka tear-off).
2316 closureFromTearOff(receiver, 2321 closureFromTearOff(receiver,
2317 functions, 2322 functions,
2318 reflectionInfo, 2323 reflectionInfo,
2319 isStatic, 2324 isStatic,
2320 jsArguments, 2325 jsArguments,
2321 name) { 2326 name) {
2322 return Closure.fromTearOff( 2327 return Closure.fromTearOff(
2323 receiver, 2328 receiver,
2324 JSArray.markFixedList(functions), 2329 JSArray.markFixedList(functions),
2325 JSArray.markFixedList(reflectionInfo), 2330 reflectionInfo is List ? JSArray.markFixedList(reflectionInfo)
2331 : reflectionInfo,
2326 JS('bool', '!!#', isStatic), 2332 JS('bool', '!!#', isStatic),
2327 jsArguments, 2333 jsArguments,
2328 JS('String', '#', name)); 2334 JS('String', '#', name));
2329 } 2335 }
2330 2336
2331 /// Represents an implicit closure of a function. 2337 /// Represents an implicit closure of a function.
2332 class TearOffClosure extends Closure { 2338 class TearOffClosure extends Closure {
2333 } 2339 }
2334 2340
2335 /// Represents a 'tear-off' closure, that is an instance method bound 2341 /// Represents a 'tear-off' closure, that is an instance method bound
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after
3448 throw new MainError("No top-level function named 'main'."); 3454 throw new MainError("No top-level function named 'main'.");
3449 } 3455 }
3450 3456
3451 void badMain() { 3457 void badMain() {
3452 throw new MainError("'main' is not a function."); 3458 throw new MainError("'main' is not a function.");
3453 } 3459 }
3454 3460
3455 void mainHasTooManyParameters() { 3461 void mainHasTooManyParameters() {
3456 throw new MainError("'main' expects too many parameters."); 3462 throw new MainError("'main' expects too many parameters.");
3457 } 3463 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698