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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 11548027: Implement is-checks for closures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 js_backend; 5 part of js_backend;
6 6
7 /** 7 /**
8 * A function element that represents a closure call. The signature is copied 8 * A function element that represents a closure call. The signature is copied
9 * from the given element. 9 * from the given element.
10 */ 10 */
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 if (checkedClasses.contains(cls)) { 1049 if (checkedClasses.contains(cls)) {
1050 emitIsTest(cls); 1050 emitIsTest(cls);
1051 } 1051 }
1052 1052
1053 Set<Element> generated = new Set<Element>(); 1053 Set<Element> generated = new Set<Element>();
1054 // A class that defines a [:call:] method implicitly implements 1054 // A class that defines a [:call:] method implicitly implements
1055 // [Function] and needs checks for all typedefs that are used in is-checks. 1055 // [Function] and needs checks for all typedefs that are used in is-checks.
1056 if (checkedClasses.contains(compiler.functionClass) || 1056 if (checkedClasses.contains(compiler.functionClass) ||
1057 !checkedTypedefs.isEmpty) { 1057 !checkedTypedefs.isEmpty) {
1058 FunctionElement call = cls.lookupLocalMember(Compiler.CALL_OPERATOR_NAME); 1058 FunctionElement call = cls.lookupLocalMember(Compiler.CALL_OPERATOR_NAME);
1059 if (call == null) {
1060 // If [cls] is a closure, it has a synthetic call operator method.
ngeoffray 2012/12/12 13:28:02 Please add a cls.lookupBackendMember.
1061 for (Element element in cls.backendMembers) {
1062 if (element.name == Compiler.CALL_OPERATOR_NAME) {
1063 call = element;
1064 break;
1065 }
1066 }
1067 }
1059 if (call != null) { 1068 if (call != null) {
1060 generateInterfacesIsTests(compiler.functionClass, 1069 generateInterfacesIsTests(compiler.functionClass,
1061 emitIsTest, 1070 emitIsTest,
1062 generated); 1071 generated);
1063 FunctionType callType = call.computeType(compiler); 1072 FunctionType callType = call.computeType(compiler);
1064 for (TypedefElement typedef in checkedTypedefs) { 1073 for (TypedefElement typedef in checkedTypedefs) {
1065 FunctionType typedefType = 1074 FunctionType typedefType =
1066 typedef.computeType(compiler).unalias(compiler); 1075 typedef.computeType(compiler).unalias(compiler);
1067 if (compiler.types.isSubtype(callType, typedefType)) { 1076 if (compiler.types.isSubtype(callType, typedefType)) {
1068 emitIsTest(typedef); 1077 emitIsTest(typedef);
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 const String HOOKS_API_USAGE = """ 1983 const String HOOKS_API_USAGE = """
1975 // Generated by dart2js, the Dart to JavaScript compiler. 1984 // Generated by dart2js, the Dart to JavaScript compiler.
1976 // The code supports the following hooks: 1985 // The code supports the following hooks:
1977 // dartPrint(message) - if this function is defined it is called 1986 // dartPrint(message) - if this function is defined it is called
1978 // instead of the Dart [print] method. 1987 // instead of the Dart [print] method.
1979 // dartMainRunner(main) - if this function is defined, the Dart [main] 1988 // dartMainRunner(main) - if this function is defined, the Dart [main]
1980 // method will not be invoked directly. 1989 // method will not be invoked directly.
1981 // Instead, a closure that will invoke [main] is 1990 // Instead, a closure that will invoke [main] is
1982 // passed to [dartMainRunner]. 1991 // passed to [dartMainRunner].
1983 """; 1992 """;
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698