Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 elements.modelx; | 5 library elements.modelx; |
| 6 | 6 |
| 7 import 'dart:collection' show LinkedHashMap; | 7 import 'dart:collection' show LinkedHashMap; |
| 8 | 8 |
| 9 import 'elements.dart'; | 9 import 'elements.dart'; |
| 10 import '../../compiler.dart' as api; | 10 import '../../compiler.dart' as api; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 } | 310 } |
| 311 | 311 |
| 312 Link<MetadataAnnotation> get metadata => unsupported(); | 312 Link<MetadataAnnotation> get metadata => unsupported(); |
| 313 get type => unsupported(); | 313 get type => unsupported(); |
| 314 get cachedNode => unsupported(); | 314 get cachedNode => unsupported(); |
| 315 get functionSignature => unsupported(); | 315 get functionSignature => unsupported(); |
| 316 get patch => unsupported(); | 316 get patch => unsupported(); |
| 317 get origin => unsupported(); | 317 get origin => unsupported(); |
| 318 get defaultImplementation => unsupported(); | 318 get defaultImplementation => unsupported(); |
| 319 | 319 |
| 320 bool get isRedirection => unsupported(); | |
| 320 bool get isPatched => unsupported(); | 321 bool get isPatched => unsupported(); |
| 321 bool get isPatch => unsupported(); | 322 bool get isPatch => unsupported(); |
| 322 | 323 |
| 323 setPatch(patch) => unsupported(); | 324 setPatch(patch) => unsupported(); |
| 324 computeSignature(compiler) => unsupported(); | 325 computeSignature(compiler) => unsupported(); |
| 325 requiredParameterCount(compiler) => unsupported(); | 326 requiredParameterCount(compiler) => unsupported(); |
| 326 optionalParameterCount(compiler) => unsupported(); | 327 optionalParameterCount(compiler) => unsupported(); |
| 327 parameterCount(compiler) => unsupported(); | 328 parameterCount(compiler) => unsupported(); |
| 328 | 329 |
| 329 // TODO(kasperl): These seem unnecessary. | 330 // TODO(kasperl): These seem unnecessary. |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1086 forEachRequiredParameter(function); | 1087 forEachRequiredParameter(function); |
| 1087 forEachOptionalParameter(function); | 1088 forEachOptionalParameter(function); |
| 1088 } | 1089 } |
| 1089 | 1090 |
| 1090 void orderedForEachParameter(void function(Element parameter)) { | 1091 void orderedForEachParameter(void function(Element parameter)) { |
| 1091 forEachRequiredParameter(function); | 1092 forEachRequiredParameter(function); |
| 1092 orderedOptionalParameters.forEach(function); | 1093 orderedOptionalParameters.forEach(function); |
| 1093 } | 1094 } |
| 1094 | 1095 |
| 1095 int get parameterCount => requiredParameterCount + optionalParameterCount; | 1096 int get parameterCount => requiredParameterCount + optionalParameterCount; |
| 1097 | |
| 1098 /** | |
| 1099 * Check whether a function with this signature can be used instead of a | |
| 1100 * function with signature [signature] without causing a `noSuchMethod` | |
| 1101 * exception/call. | |
| 1102 */ | |
| 1103 bool isCompatibleWith(FunctionSignature signature) { | |
| 1104 if (optionalParametersAreNamed != signature.optionalParametersAreNamed) { | |
| 1105 return false; | |
| 1106 } | |
| 1107 if (optionalParametersAreNamed) { | |
| 1108 if (requiredParameterCount != signature.requiredParameterCount) { | |
| 1109 return false; | |
| 1110 } | |
| 1111 for (Element namedParameter in signature.orderedOptionalParameters) { | |
|
ngeoffray
2013/05/30 11:57:23
I don't think you need the ordered version.
karlklose
2013/05/30 12:24:41
Yes, changed to optionalParameters.
| |
| 1112 if (!orderedOptionalParameters.contains(namedParameter)) { | |
| 1113 return false; | |
| 1114 } | |
| 1115 } | |
| 1116 } else { | |
| 1117 if (requiredParameterCount > signature.requiredParameterCount || | |
|
ngeoffray
2013/05/30 11:57:23
Please add a comment how it is ok to have more par
karlklose
2013/05/30 12:24:41
Done.
| |
| 1118 requiredParameterCount < signature.parameterCount || | |
| 1119 parameterCount < signature.parameterCount) { | |
| 1120 return false; | |
| 1121 } | |
| 1122 } | |
| 1123 return true; | |
| 1124 } | |
| 1096 } | 1125 } |
| 1097 | 1126 |
| 1098 class FunctionElementX extends ElementX implements FunctionElement { | 1127 class FunctionElementX extends ElementX implements FunctionElement { |
| 1099 FunctionExpression cachedNode; | 1128 FunctionExpression cachedNode; |
| 1100 DartType type; | 1129 DartType type; |
| 1101 final Modifiers modifiers; | 1130 final Modifiers modifiers; |
| 1102 | 1131 |
| 1103 FunctionSignature functionSignature; | 1132 FunctionSignature functionSignature; |
| 1104 | 1133 |
| 1105 /** | 1134 /** |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1145 Element enclosing, | 1174 Element enclosing, |
| 1146 FunctionSignature this.functionSignature) | 1175 FunctionSignature this.functionSignature) |
| 1147 : super(name, kind, enclosing) { | 1176 : super(name, kind, enclosing) { |
| 1148 assert(modifiers != null); | 1177 assert(modifiers != null); |
| 1149 defaultImplementation = this; | 1178 defaultImplementation = this; |
| 1150 } | 1179 } |
| 1151 | 1180 |
| 1152 bool get isPatched => patch != null; | 1181 bool get isPatched => patch != null; |
| 1153 bool get isPatch => origin != null; | 1182 bool get isPatch => origin != null; |
| 1154 | 1183 |
| 1184 bool get isRedirection => defaultImplementation != this; | |
| 1185 | |
| 1155 FunctionElement get redirectionTarget { | 1186 FunctionElement get redirectionTarget { |
| 1156 if (this == defaultImplementation) return this; | 1187 if (this == defaultImplementation) return this; |
| 1157 var target = defaultImplementation; | 1188 var target = defaultImplementation; |
| 1158 Set<Element> seen = new Set<Element>(); | 1189 Set<Element> seen = new Set<Element>(); |
| 1159 seen.add(target); | 1190 seen.add(target); |
| 1160 while (!target.isErroneous() && target != target.defaultImplementation) { | 1191 while (!target.isErroneous() && target != target.defaultImplementation) { |
| 1161 target = target.defaultImplementation; | 1192 target = target.defaultImplementation; |
| 1162 if (seen.contains(target)) { | 1193 if (seen.contains(target)) { |
| 1163 // TODO(ahe): This is expedient for now, but it should be | 1194 // TODO(ahe): This is expedient for now, but it should be |
| 1164 // checked by the resolver. Keeping http://dartbug.com/3970 | 1195 // checked by the resolver. Keeping http://dartbug.com/3970 |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2098 | 2129 |
| 2099 MetadataAnnotation ensureResolved(Compiler compiler) { | 2130 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 2100 if (resolutionState == STATE_NOT_STARTED) { | 2131 if (resolutionState == STATE_NOT_STARTED) { |
| 2101 compiler.resolver.resolveMetadataAnnotation(this); | 2132 compiler.resolver.resolveMetadataAnnotation(this); |
| 2102 } | 2133 } |
| 2103 return this; | 2134 return this; |
| 2104 } | 2135 } |
| 2105 | 2136 |
| 2106 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 2137 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 2107 } | 2138 } |
| OLD | NEW |