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

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

Issue 1158693003: dart2js cps: Change how type variables are accessed in constructors. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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 // 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 'constants/expressions.dart'; 7 import 'constants/expressions.dart';
8 import 'dart2jslib.dart'; 8 import 'dart2jslib.dart';
9 import 'dart_types.dart'; 9 import 'dart_types.dart';
10 import 'elements/elements.dart'; 10 import 'elements/elements.dart';
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 } 734 }
735 } 735 }
736 } 736 }
737 737
738 visitIdentifier(Identifier node) { 738 visitIdentifier(Identifier node) {
739 if (node.isThis()) { 739 if (node.isThis()) {
740 registerNeedsThis(); 740 registerNeedsThis();
741 } else { 741 } else {
742 Element element = elements[node]; 742 Element element = elements[node];
743 if (element != null && element.isTypeVariable) { 743 if (element != null && element.isTypeVariable) {
744 if (outermostElement.isConstructor) { 744 if (outermostElement.isConstructor ||
745 outermostElement.isField) {
745 TypeVariableElement typeVariable = element; 746 TypeVariableElement typeVariable = element;
746 useTypeVariableAsLocal(typeVariable.type); 747 useTypeVariableAsLocal(typeVariable.type);
747 } else { 748 } else {
748 registerNeedsThis(); 749 registerNeedsThis();
749 } 750 }
750 } 751 }
751 } 752 }
752 node.visitChildren(this); 753 node.visitChildren(this);
753 } 754 }
754 755
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 } 1075 }
1075 1076
1076 visitTryStatement(TryStatement node) { 1077 visitTryStatement(TryStatement node) {
1077 // TODO(ngeoffray): implement finer grain state. 1078 // TODO(ngeoffray): implement finer grain state.
1078 bool oldInTryStatement = inTryStatement; 1079 bool oldInTryStatement = inTryStatement;
1079 inTryStatement = true; 1080 inTryStatement = true;
1080 node.visitChildren(this); 1081 node.visitChildren(this);
1081 inTryStatement = oldInTryStatement; 1082 inTryStatement = oldInTryStatement;
1082 } 1083 }
1083 1084
1085 visitCatchBlock(CatchBlock node) {
1086 if (node.type != null) {
1087 // The "on T" clause may contain type variables.
1088 analyzeType(elements.getType(node.type));
1089 }
1090 if (node.formals != null) node.formals.visitChildren(this);
karlklose 2015/05/28 08:12:19 Use {}.
asgerf 2015/05/28 09:34:21 Done.
1091 node.block.accept(this);
1092 }
1093
1084 visitAsyncForIn(AsyncForIn node) { 1094 visitAsyncForIn(AsyncForIn node) {
1085 // An `await for` loop is enclosed in an implicit try-finally. 1095 // An `await for` loop is enclosed in an implicit try-finally.
1086 bool oldInTryStatement = inTryStatement; 1096 bool oldInTryStatement = inTryStatement;
1087 inTryStatement = true; 1097 inTryStatement = true;
1088 visitLoop(node); 1098 visitLoop(node);
1089 inTryStatement = oldInTryStatement; 1099 inTryStatement = oldInTryStatement;
1090 } 1100 }
1091 } 1101 }
1092 1102
1093 /// A type variable as a local variable. 1103 /// A type variable as a local variable.
1094 class TypeVariableLocal implements Local { 1104 class TypeVariableLocal implements Local {
1095 final TypeVariableType typeVariable; 1105 final TypeVariableType typeVariable;
1096 final ExecutableElement executableContext; 1106 final ExecutableElement executableContext;
1097 1107
1098 TypeVariableLocal(this.typeVariable, this.executableContext); 1108 TypeVariableLocal(this.typeVariable, this.executableContext);
1099 1109
1100 String get name => typeVariable.name; 1110 String get name => typeVariable.name;
1101 1111
1102 int get hashCode => typeVariable.hashCode; 1112 int get hashCode => typeVariable.hashCode;
1103 1113
1104 bool operator ==(other) { 1114 bool operator ==(other) {
1105 if (other is! TypeVariableLocal) return false; 1115 if (other is! TypeVariableLocal) return false;
1106 return typeVariable == other.typeVariable; 1116 return typeVariable == other.typeVariable;
1107 } 1117 }
1108 } 1118 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart » ('j') | pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698