| 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 isRedirectingFactory => 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.optionalParameters) { |
| 1112 if (!optionalParameters.contains(namedParameter)) { |
| 1113 return false; |
| 1114 } |
| 1115 } |
| 1116 } else { |
| 1117 // There must be at least as many arguments as in the other signature, but |
| 1118 // this signature must not have more required paramters. Having more |
| 1119 // optional parameters is not a problem, they simply are never provided |
| 1120 // by call sites of a call to a method with the other signature. |
| 1121 if (requiredParameterCount > signature.requiredParameterCount || |
| 1122 requiredParameterCount < signature.parameterCount || |
| 1123 parameterCount < signature.parameterCount) { |
| 1124 return false; |
| 1125 } |
| 1126 } |
| 1127 return true; |
| 1128 } |
| 1096 } | 1129 } |
| 1097 | 1130 |
| 1098 class FunctionElementX extends ElementX implements FunctionElement { | 1131 class FunctionElementX extends ElementX implements FunctionElement { |
| 1099 FunctionExpression cachedNode; | 1132 FunctionExpression cachedNode; |
| 1100 DartType type; | 1133 DartType type; |
| 1101 final Modifiers modifiers; | 1134 final Modifiers modifiers; |
| 1102 | 1135 |
| 1103 FunctionSignature functionSignature; | 1136 FunctionSignature functionSignature; |
| 1104 | 1137 |
| 1105 /** | 1138 /** |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 Element enclosing, | 1178 Element enclosing, |
| 1146 FunctionSignature this.functionSignature) | 1179 FunctionSignature this.functionSignature) |
| 1147 : super(name, kind, enclosing) { | 1180 : super(name, kind, enclosing) { |
| 1148 assert(modifiers != null); | 1181 assert(modifiers != null); |
| 1149 defaultImplementation = this; | 1182 defaultImplementation = this; |
| 1150 } | 1183 } |
| 1151 | 1184 |
| 1152 bool get isPatched => patch != null; | 1185 bool get isPatched => patch != null; |
| 1153 bool get isPatch => origin != null; | 1186 bool get isPatch => origin != null; |
| 1154 | 1187 |
| 1188 bool get isRedirectingFactory => defaultImplementation != this; |
| 1189 |
| 1155 FunctionElement get redirectionTarget { | 1190 FunctionElement get redirectionTarget { |
| 1156 if (this == defaultImplementation) return this; | 1191 if (this == defaultImplementation) return this; |
| 1157 var target = defaultImplementation; | 1192 var target = defaultImplementation; |
| 1158 Set<Element> seen = new Set<Element>(); | 1193 Set<Element> seen = new Set<Element>(); |
| 1159 seen.add(target); | 1194 seen.add(target); |
| 1160 while (!target.isErroneous() && target != target.defaultImplementation) { | 1195 while (!target.isErroneous() && target != target.defaultImplementation) { |
| 1161 target = target.defaultImplementation; | 1196 target = target.defaultImplementation; |
| 1162 if (seen.contains(target)) { | 1197 if (seen.contains(target)) { |
| 1163 // TODO(ahe): This is expedient for now, but it should be | 1198 // TODO(ahe): This is expedient for now, but it should be |
| 1164 // checked by the resolver. Keeping http://dartbug.com/3970 | 1199 // checked by the resolver. Keeping http://dartbug.com/3970 |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2098 | 2133 |
| 2099 MetadataAnnotation ensureResolved(Compiler compiler) { | 2134 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 2100 if (resolutionState == STATE_NOT_STARTED) { | 2135 if (resolutionState == STATE_NOT_STARTED) { |
| 2101 compiler.resolver.resolveMetadataAnnotation(this); | 2136 compiler.resolver.resolveMetadataAnnotation(this); |
| 2102 } | 2137 } |
| 2103 return this; | 2138 return this; |
| 2104 } | 2139 } |
| 2105 | 2140 |
| 2106 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 2141 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 2107 } | 2142 } |
| OLD | NEW |