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

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: Add ClassElement.lookupBackendMember. 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
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 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 if (checkedClasses.contains(cls)) { 1077 if (checkedClasses.contains(cls)) {
1078 emitIsTest(cls); 1078 emitIsTest(cls);
1079 } 1079 }
1080 1080
1081 Set<Element> generated = new Set<Element>(); 1081 Set<Element> generated = new Set<Element>();
1082 // A class that defines a [:call:] method implicitly implements 1082 // A class that defines a [:call:] method implicitly implements
1083 // [Function] and needs checks for all typedefs that are used in is-checks. 1083 // [Function] and needs checks for all typedefs that are used in is-checks.
1084 if (checkedClasses.contains(compiler.functionClass) || 1084 if (checkedClasses.contains(compiler.functionClass) ||
1085 !checkedTypedefs.isEmpty) { 1085 !checkedTypedefs.isEmpty) {
1086 FunctionElement call = cls.lookupLocalMember(Compiler.CALL_OPERATOR_NAME); 1086 FunctionElement call = cls.lookupLocalMember(Compiler.CALL_OPERATOR_NAME);
1087 if (call == null) {
1088 // If [cls] is a closure, it has a synthetic call operator method.
1089 call = cls.lookupBackendMember(Compiler.CALL_OPERATOR_NAME);
1090 }
1087 if (call != null) { 1091 if (call != null) {
1088 generateInterfacesIsTests(compiler.functionClass, 1092 generateInterfacesIsTests(compiler.functionClass,
1089 emitIsTest, 1093 emitIsTest,
1090 generated); 1094 generated);
1091 FunctionType callType = call.computeType(compiler); 1095 FunctionType callType = call.computeType(compiler);
1092 for (TypedefElement typedef in checkedTypedefs) { 1096 for (TypedefElement typedef in checkedTypedefs) {
1093 FunctionType typedefType = 1097 FunctionType typedefType =
1094 typedef.computeType(compiler).unalias(compiler); 1098 typedef.computeType(compiler).unalias(compiler);
1095 if (compiler.types.isSubtype(callType, typedefType)) { 1099 if (compiler.types.isSubtype(callType, typedefType)) {
1096 emitIsTest(typedef); 1100 emitIsTest(typedef);
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 """; 2020 """;
2017 const String HOOKS_API_USAGE = """ 2021 const String HOOKS_API_USAGE = """
2018 // The code supports the following hooks: 2022 // The code supports the following hooks:
2019 // dartPrint(message) - if this function is defined it is called 2023 // dartPrint(message) - if this function is defined it is called
2020 // instead of the Dart [print] method. 2024 // instead of the Dart [print] method.
2021 // dartMainRunner(main) - if this function is defined, the Dart [main] 2025 // dartMainRunner(main) - if this function is defined, the Dart [main]
2022 // method will not be invoked directly. 2026 // method will not be invoked directly.
2023 // Instead, a closure that will invoke [main] is 2027 // Instead, a closure that will invoke [main] is
2024 // passed to [dartMainRunner]. 2028 // passed to [dartMainRunner].
2025 """; 2029 """;
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/elements/elements.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698