OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 } |
OLD | NEW |