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

Side by Side Diff: pkg/compiler/lib/src/closure.dart

Issue 851303002: dart2js: capture type variables in closures, if they are only used in literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix test. Created 5 years, 11 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) 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 library closureToClassMapper; 5 library closureToClassMapper;
6 6
7 import "elements/elements.dart"; 7 import "elements/elements.dart";
8 import "dart2jslib.dart"; 8 import "dart2jslib.dart";
9 import "dart_types.dart"; 9 import "dart_types.dart";
10 import "js_backend/js_backend.dart" show JavaScriptBackend; 10 import "js_backend/js_backend.dart" show JavaScriptBackend;
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 } 724 }
725 super.visitSendSet(node); 725 super.visitSendSet(node);
726 } 726 }
727 727
728 visitNewExpression(NewExpression node) { 728 visitNewExpression(NewExpression node) {
729 DartType type = elements.getType(node); 729 DartType type = elements.getType(node);
730 analyzeType(type); 730 analyzeType(type);
731 node.visitChildren(this); 731 node.visitChildren(this);
732 } 732 }
733 733
734 visitLiteralList(LiteralList node) {
735 DartType type = elements.getType(node);
736 analyzeType(type);
737 node.visitChildren(this);
738 }
739
740 visitLiteralMap(LiteralMap node) {
741 DartType type = elements.getType(node);
742 analyzeType(type);
743 node.visitChildren(this);
744 }
745
734 void analyzeTypeVariables(DartType type) { 746 void analyzeTypeVariables(DartType type) {
735 type.forEachTypeVariable((TypeVariableType typeVariable) { 747 type.forEachTypeVariable((TypeVariableType typeVariable) {
736 // Field initializers are inlined and access the type variable as 748 // Field initializers are inlined and access the type variable as
737 // normal parameters. 749 // normal parameters.
738 if (!outermostElement.isField && 750 if (!outermostElement.isField &&
739 !outermostElement.isConstructor) { 751 !outermostElement.isConstructor) {
740 registerNeedsThis(); 752 registerNeedsThis();
741 } else { 753 } else {
742 useTypeVariableAsLocal(typeVariable); 754 useTypeVariableAsLocal(typeVariable);
743 } 755 }
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 1027
1016 String get name => typeVariable.name; 1028 String get name => typeVariable.name;
1017 1029
1018 int get hashCode => typeVariable.hashCode; 1030 int get hashCode => typeVariable.hashCode;
1019 1031
1020 bool operator ==(other) { 1032 bool operator ==(other) {
1021 if (other is! TypeVariableLocal) return false; 1033 if (other is! TypeVariableLocal) return false;
1022 return typeVariable == other.typeVariable; 1034 return typeVariable == other.typeVariable;
1023 } 1035 }
1024 } 1036 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/type_variable_closure2_test.dart » ('j') | tests/language/type_variable_closure2_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698