Chromium Code Reviews| 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 part of resolution; | 5 part of resolution; |
| 6 | 6 |
| 7 abstract class TreeElements { | 7 abstract class TreeElements { |
| 8 Element operator[](Node node); | 8 Element operator[](Node node); |
| 9 Selector getSelector(Send send); | 9 Selector getSelector(Send send); |
| 10 DartType getType(Node node); | 10 DartType getType(Node node); |
| (...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1031 breakTargetStack = breakTargetStack.tail; | 1031 breakTargetStack = breakTargetStack.tail; |
| 1032 labels = labels.outer; | 1032 labels = labels.outer; |
| 1033 } | 1033 } |
| 1034 } | 1034 } |
| 1035 | 1035 |
| 1036 class TypeResolver { | 1036 class TypeResolver { |
| 1037 final Compiler compiler; | 1037 final Compiler compiler; |
| 1038 | 1038 |
| 1039 TypeResolver(this.compiler); | 1039 TypeResolver(this.compiler); |
| 1040 | 1040 |
| 1041 bool anyMalformedTypesInThere(Link<DartType> list) { | 1041 bool anyMalformedTypes(Link<DartType> list) { |
| 1042 for (Link<DartType> link = list; | 1042 for (Link<DartType> link = list; |
| 1043 !link.isEmpty; | 1043 !link.isEmpty; |
| 1044 link = link.tail) { | 1044 link = link.tail) { |
| 1045 DartType dtype = link.head; | 1045 DartType dtype = link.head; |
| 1046 if (dtype is MalformedType) { | 1046 if (dtype is MalformedType) { |
| 1047 return true; | 1047 return true; |
| 1048 } | 1048 } |
| 1049 } | 1049 } |
| 1050 return false; | 1050 return false; |
| 1051 } | 1051 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1129 ClassElement cls = element; | 1129 ClassElement cls = element; |
| 1130 cls.ensureResolved(compiler); | 1130 cls.ensureResolved(compiler); |
| 1131 Link<DartType> arguments = | 1131 Link<DartType> arguments = |
| 1132 resolveTypeArguments(node, cls.typeVariables, | 1132 resolveTypeArguments(node, cls.typeVariables, |
| 1133 inStaticContext, scope, | 1133 inStaticContext, scope, |
| 1134 onFailure, whenResolved); | 1134 onFailure, whenResolved); |
| 1135 if (cls.typeVariables.isEmpty && arguments.isEmpty) { | 1135 if (cls.typeVariables.isEmpty && arguments.isEmpty) { |
| 1136 // Use the canonical type if it has no type parameters. | 1136 // Use the canonical type if it has no type parameters. |
| 1137 type = cls.computeType(compiler); | 1137 type = cls.computeType(compiler); |
| 1138 } else { | 1138 } else { |
| 1139 // In checked mode malformed-ness of the type argument bubbles up. | 1139 if (anyMalformedTypes(arguments)) { |
| 1140 if (anyMalformedTypesInThere(arguments) && | 1140 // Build interface type(with malformed arguments in it) and |
| 1141 compiler.enableTypeAssertions) { | 1141 // map it to this constructor invocation node(that's what |
|
ngeoffray
2012/11/29 09:02:26
missing space after node.
aam-me
2012/11/30 06:27:47
Done.
| |
| 1142 type = new MalformedType( | 1142 // whenResolved does), so that ssaBuilder visitNewSend |
|
ngeoffray
2012/11/29 09:02:26
you can write [SsaBuilder.visitNewSend]
aam-me
2012/11/30 06:27:47
Done.
| |
| 1143 new MalformedTypeElement(node, element)); | 1143 // can figure out which constructor to call. |
| 1144 type = new InterfaceType(cls.declaration, arguments); | |
|
ngeoffray
2012/11/29 09:02:26
I wouldn't re-use the 'type' variable here, it mak
aam-me
2012/11/30 06:27:47
Done.
| |
| 1145 whenResolved(node, type); | |
| 1146 // However return malformed type element so that | |
| 1147 // ConstructorResolver.visitTypeAnnotation gets [:MalformedType:] | |
|
ngeoffray
2012/11/29 09:02:26
[ConstructorResolver.visitTypeAnnotation]
aam-me
2012/11/30 06:27:47
Done.
| |
| 1148 // and decorates new expression with this malformed type. | |
|
ngeoffray
2012/11/29 09:02:26
What means 'decorates' here?
aam-me
2012/11/30 06:27:47
I meant "maps new expression to malformed type". F
| |
| 1149 // The fact that new expression has malformed type is picked up | |
| 1150 // by ssaBuilder visitNewExpression, but doesn't affect ssaBuilder | |
|
ngeoffray
2012/11/29 09:02:26
[SsaBuilder..]
aam-me
2012/11/30 06:27:47
Done.
| |
| 1151 // [:visitNewSend:] (important not to affect it in production mode) | |
|
ngeoffray
2012/11/29 09:02:26
[SsaBuilder.visitNewSend].
| |
| 1152 // since it doesn't use type we create below, but follows the | |
|
ngeoffray
2012/11/29 09:02:26
use the type we created below
| |
| 1153 // mapping we created above from Send node element | |
|
ngeoffray
2012/11/29 09:02:26
what's 'from Send node element' ? Is that the elem
aam-me
2012/11/30 06:27:47
"Send node" is a parameter to [SsaBuilder.visitNew
| |
| 1154 // to InterfaceType. | |
| 1155 type = new MalformedType(new MalformedTypeElement(node, element)); | |
| 1156 return type; | |
| 1144 } else { | 1157 } else { |
| 1145 if (arguments.isEmpty) { | 1158 if (arguments.isEmpty) { |
| 1146 // Use the canonical raw type if the class is generic. | 1159 // Use the canonical raw type if the class is generic. |
| 1147 type = cls.rawType; | 1160 type = cls.rawType; |
| 1148 } else { | 1161 } else { |
| 1149 type = new InterfaceType(cls.declaration, arguments); | 1162 type = new InterfaceType(cls.declaration, arguments); |
| 1150 } | 1163 } |
| 1151 } | 1164 } |
| 1152 } | 1165 } |
| 1153 } else if (element.isTypedef()) { | 1166 } else if (element.isTypedef()) { |
| (...skipping 2005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3159 return e; | 3172 return e; |
| 3160 } | 3173 } |
| 3161 | 3174 |
| 3162 /// Assumed to be called by [resolveRedirectingFactory]. | 3175 /// Assumed to be called by [resolveRedirectingFactory]. |
| 3163 Element visitReturn(Return node) { | 3176 Element visitReturn(Return node) { |
| 3164 Node expression = node.expression; | 3177 Node expression = node.expression; |
| 3165 return finishConstructorReference(visit(expression), | 3178 return finishConstructorReference(visit(expression), |
| 3166 expression, expression); | 3179 expression, expression); |
| 3167 } | 3180 } |
| 3168 } | 3181 } |
| OLD | NEW |