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 '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/names.dart' show Identifiers; | 8 import '../common/names.dart' show Identifiers; |
| 9 import '../common/resolution.dart' show Resolution, ParsingContext; | 9 import '../common/resolution.dart' show Resolution, ParsingContext; |
| 10 import '../compiler.dart' show Compiler; | 10 import '../compiler.dart' show Compiler; |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 set typeCache(_) { | 391 set typeCache(_) { |
| 392 throw new UnsupportedError("typeCache="); | 392 throw new UnsupportedError("typeCache="); |
| 393 } | 393 } |
| 394 | 394 |
| 395 @override | 395 @override |
| 396 get immediateRedirectionTarget { | 396 get immediateRedirectionTarget { |
| 397 throw new UnsupportedError("immediateRedirectionTarget"); | 397 throw new UnsupportedError("immediateRedirectionTarget"); |
| 398 } | 398 } |
| 399 | 399 |
| 400 @override | 400 @override |
| 401 set immediateRedirectionTarget(_) { | 401 get _immediateRedirectionTarget { |
| 402 throw new UnsupportedError("immediateRedirectionTarget="); | 402 throw new UnsupportedError("_immediateRedirectionTarget"); |
| 403 } | 403 } |
| 404 | 404 |
| 405 @override | 405 @override |
| 406 set _immediateRedirectionTarget(_) { | |
| 407 throw new UnsupportedError("_immediateRedirectionTarget="); | |
| 408 } | |
| 409 | |
| 410 @override | |
| 411 setImmediateRedirectionTarget(a, b) { | |
| 412 throw new UnsupportedError("setImmediateRedirectionTarget="); | |
|
Harry Terkelsen
2016/07/06 16:40:07
nit: remove the '='
Johnni Winther
2016/07/08 09:17:26
Done.
| |
| 413 } | |
| 414 | |
| 415 @override | |
| 406 get _functionSignatureCache { | 416 get _functionSignatureCache { |
| 407 throw new UnsupportedError("functionSignatureCache"); | 417 throw new UnsupportedError("functionSignatureCache"); |
| 408 } | 418 } |
| 409 | 419 |
| 410 @override | 420 @override |
| 411 set _functionSignatureCache(_) { | 421 set _functionSignatureCache(_) { |
| 412 throw new UnsupportedError("functionSignatureCache="); | 422 throw new UnsupportedError("functionSignatureCache="); |
| 413 } | 423 } |
| 414 | 424 |
| 415 @override | 425 @override |
| 416 set functionSignature(_) { | 426 set functionSignature(_) { |
| 417 throw new UnsupportedError("functionSignature="); | 427 throw new UnsupportedError("functionSignature="); |
| 418 } | 428 } |
| 419 | 429 |
| 420 @override | 430 @override |
| 421 get nestedClosures { | 431 get nestedClosures { |
| 422 throw new UnsupportedError("nestedClosures"); | 432 throw new UnsupportedError("nestedClosures"); |
| 423 } | 433 } |
| 424 | 434 |
| 425 @override | 435 @override |
| 426 set nestedClosures(_) { | 436 set nestedClosures(_) { |
| 427 throw new UnsupportedError("nestedClosures="); | 437 throw new UnsupportedError("nestedClosures="); |
| 428 } | 438 } |
| 429 | 439 |
| 430 @override | 440 @override |
| 431 set redirectionDeferredPrefix(_) { | 441 get _redirectionDeferredPrefix { |
| 432 throw new UnsupportedError("redirectionDeferredPrefix="); | 442 throw new UnsupportedError("_redirectionDeferredPrefix"); |
| 443 } | |
| 444 | |
| 445 @override | |
| 446 set _redirectionDeferredPrefix(_) { | |
| 447 throw new UnsupportedError("_redirectionDeferredPrefix="); | |
| 433 } | 448 } |
| 434 } | 449 } |
| 435 | 450 |
| 436 /// A message attached to a [WarnOnUseElementX]. | 451 /// A message attached to a [WarnOnUseElementX]. |
| 437 class WrappedMessage { | 452 class WrappedMessage { |
| 438 /// The message position. If [:null:] the position of the reference to the | 453 /// The message position. If [:null:] the position of the reference to the |
| 439 /// [WarnOnUseElementX] is used. | 454 /// [WarnOnUseElementX] is used. |
| 440 final Spannable spannable; | 455 final Spannable spannable; |
| 441 | 456 |
| 442 /** | 457 /** |
| (...skipping 1747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2190 | 2205 |
| 2191 abstract class ConstructorElementX extends FunctionElementX | 2206 abstract class ConstructorElementX extends FunctionElementX |
| 2192 with ConstantConstructorMixin, ConstructorElementCommon | 2207 with ConstantConstructorMixin, ConstructorElementCommon |
| 2193 implements ConstructorElement { | 2208 implements ConstructorElement { |
| 2194 bool isRedirectingGenerative = false; | 2209 bool isRedirectingGenerative = false; |
| 2195 | 2210 |
| 2196 ConstructorElementX( | 2211 ConstructorElementX( |
| 2197 String name, ElementKind kind, Modifiers modifiers, Element enclosing) | 2212 String name, ElementKind kind, Modifiers modifiers, Element enclosing) |
| 2198 : super(name, kind, modifiers, enclosing); | 2213 : super(name, kind, modifiers, enclosing); |
| 2199 | 2214 |
| 2200 FunctionElement immediateRedirectionTarget; | 2215 ConstructorElement _immediateRedirectionTarget; |
| 2201 PrefixElement redirectionDeferredPrefix; | 2216 PrefixElement _redirectionDeferredPrefix; |
| 2217 | |
| 2218 ConstructorElementX get patch => super.patch; | |
| 2202 | 2219 |
| 2203 bool get isRedirectingFactory => immediateRedirectionTarget != null; | 2220 bool get isRedirectingFactory => immediateRedirectionTarget != null; |
| 2204 | 2221 |
| 2205 // TODO(johnniwinther): This should also return true for cyclic redirecting | 2222 // TODO(johnniwinther): This should also return true for cyclic redirecting |
| 2206 // generative constructors. | 2223 // generative constructors. |
| 2207 bool get isCyclicRedirection => effectiveTarget.isRedirectingFactory; | 2224 bool get isCyclicRedirection => effectiveTarget.isRedirectingFactory; |
| 2208 | 2225 |
| 2209 /// These fields are set by the post process queue when checking for cycles. | 2226 /// These fields are set by the post process queue when checking for cycles. |
| 2210 ConstructorElement effectiveTargetInternal; | 2227 ConstructorElement effectiveTargetInternal; |
| 2211 DartType _effectiveTargetType; | 2228 DartType _effectiveTargetType; |
| 2212 bool _isEffectiveTargetMalformed; | 2229 bool _isEffectiveTargetMalformed; |
| 2213 | 2230 |
| 2214 bool get hasEffectiveTarget => effectiveTargetInternal != null; | 2231 bool get hasEffectiveTarget { |
| 2232 if (isPatched) { | |
| 2233 return patch.hasEffectiveTarget; | |
| 2234 } | |
| 2235 return effectiveTargetInternal != null; | |
| 2236 } | |
| 2237 | |
| 2238 void setImmediateRedirectionTarget( | |
| 2239 ConstructorElement target, PrefixElement prefix) { | |
| 2240 if (isPatched) { | |
| 2241 patch.setImmediateRedirectionTarget(target, prefix); | |
| 2242 } else { | |
| 2243 assert(invariant(this, _immediateRedirectionTarget == null, | |
| 2244 message: "Immediate redirection target has already been " | |
| 2245 "set on $this.")); | |
| 2246 _immediateRedirectionTarget = target; | |
| 2247 _redirectionDeferredPrefix = prefix; | |
| 2248 } | |
| 2249 } | |
| 2250 | |
| 2251 ConstructorElement get immediateRedirectionTarget { | |
| 2252 if (isPatched) { | |
| 2253 return patch.immediateRedirectionTarget; | |
| 2254 } | |
| 2255 return _immediateRedirectionTarget; | |
| 2256 } | |
| 2257 | |
| 2258 PrefixElement get redirectionDeferredPrefix { | |
| 2259 if (isPatched) { | |
| 2260 return patch.redirectionDeferredPrefix; | |
| 2261 } | |
| 2262 return _redirectionDeferredPrefix; | |
| 2263 } | |
| 2215 | 2264 |
| 2216 void setEffectiveTarget(ConstructorElement target, DartType type, | 2265 void setEffectiveTarget(ConstructorElement target, DartType type, |
| 2217 {bool isMalformed: false}) { | 2266 {bool isMalformed: false}) { |
| 2218 assert(invariant(this, target != null, | 2267 if (isPatched) { |
| 2219 message: 'No effective target provided for $this.')); | 2268 patch.setEffectiveTarget(target, type, isMalformed: isMalformed); |
| 2220 assert(invariant(this, effectiveTargetInternal == null, | 2269 } else { |
| 2221 message: 'Effective target has already been computed for $this.')); | 2270 assert(invariant(this, target != null, |
| 2222 effectiveTargetInternal = target; | 2271 message: 'No effective target provided for $this.')); |
| 2223 _effectiveTargetType = type; | 2272 assert(invariant(this, effectiveTargetInternal == null, |
| 2224 _isEffectiveTargetMalformed = isMalformed; | 2273 message: 'Effective target has already been computed for $this.')); |
| 2274 assert(invariant(this, !target.isMalformed || isMalformed, | |
| 2275 message: 'Effective target is not marked as malformed for $this: ' | |
| 2276 'target=$target, type=$type, isMalformed: $isMalformed')); | |
| 2277 assert(invariant(this, isMalformed || type.isInterfaceType, | |
| 2278 message: 'Effective target type is not an interface type for $this: ' | |
| 2279 'target=$target, type=$type, isMalformed: $isMalformed')); | |
| 2280 effectiveTargetInternal = target; | |
| 2281 _effectiveTargetType = type; | |
| 2282 _isEffectiveTargetMalformed = isMalformed; | |
| 2283 } | |
| 2225 } | 2284 } |
| 2226 | 2285 |
| 2227 ConstructorElement get effectiveTarget { | 2286 ConstructorElement get effectiveTarget { |
| 2228 if (Elements.isMalformed(immediateRedirectionTarget)) { | 2287 if (isPatched) { |
| 2229 return immediateRedirectionTarget; | 2288 return patch.effectiveTarget; |
| 2230 } | 2289 } |
| 2231 assert(!isRedirectingFactory || effectiveTargetInternal != null); | |
| 2232 if (isRedirectingFactory) { | 2290 if (isRedirectingFactory) { |
| 2291 assert(effectiveTargetInternal != null); | |
| 2233 return effectiveTargetInternal; | 2292 return effectiveTargetInternal; |
| 2234 } | 2293 } |
| 2235 if (isPatched) { | |
| 2236 return effectiveTargetInternal ?? this; | |
| 2237 } | |
| 2238 return this; | 2294 return this; |
| 2239 } | 2295 } |
| 2240 | 2296 |
| 2241 InterfaceType get effectiveTargetType { | 2297 DartType get effectiveTargetType { |
| 2298 if (isPatched) { | |
| 2299 return patch.effectiveTargetType; | |
| 2300 } | |
| 2242 assert(invariant(this, _effectiveTargetType != null, | 2301 assert(invariant(this, _effectiveTargetType != null, |
| 2243 message: 'Effective target type has not yet been computed for $this.')); | 2302 message: 'Effective target type has not yet been computed for $this.')); |
| 2244 return _effectiveTargetType; | 2303 return _effectiveTargetType; |
| 2245 } | 2304 } |
| 2246 | 2305 |
| 2247 InterfaceType computeEffectiveTargetType(InterfaceType newType) { | 2306 DartType computeEffectiveTargetType(InterfaceType newType) { |
| 2307 if (isPatched) { | |
|
Harry Terkelsen
2016/07/06 16:40:07
given how every method in this class has a differe
Johnni Winther
2016/07/08 09:17:25
Unfortunately we don't know if it is going to be p
| |
| 2308 return patch.computeEffectiveTargetType(newType); | |
| 2309 } | |
| 2248 if (!isRedirectingFactory) return newType; | 2310 if (!isRedirectingFactory) return newType; |
| 2249 return effectiveTargetType.substByContext(newType); | 2311 return effectiveTargetType.substByContext(newType); |
| 2250 } | 2312 } |
| 2251 | 2313 |
| 2252 bool get isEffectiveTargetMalformed { | 2314 bool get isEffectiveTargetMalformed { |
| 2315 if (isPatched) { | |
| 2316 return patch.isEffectiveTargetMalformed; | |
| 2317 } | |
| 2253 if (!isRedirectingFactory) return false; | 2318 if (!isRedirectingFactory) return false; |
| 2254 assert(invariant(this, _isEffectiveTargetMalformed != null, | 2319 assert(invariant(this, _isEffectiveTargetMalformed != null, |
| 2255 message: 'Malformedness has not yet been computed for $this.')); | 2320 message: 'Malformedness has not yet been computed for $this.')); |
| 2256 return _isEffectiveTargetMalformed == true; | 2321 return _isEffectiveTargetMalformed == true; |
| 2257 } | 2322 } |
| 2258 | 2323 |
| 2259 accept(ElementVisitor visitor, arg) { | 2324 accept(ElementVisitor visitor, arg) { |
| 2260 return visitor.visitConstructorElement(this, arg); | 2325 return visitor.visitConstructorElement(this, arg); |
| 2261 } | 2326 } |
| 2262 | 2327 |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3318 body = node.asFunctionExpression().body; | 3383 body = node.asFunctionExpression().body; |
| 3319 } | 3384 } |
| 3320 return new ParsedResolvedAst( | 3385 return new ParsedResolvedAst( |
| 3321 declaration, | 3386 declaration, |
| 3322 node, | 3387 node, |
| 3323 body, | 3388 body, |
| 3324 definingElement.treeElements, | 3389 definingElement.treeElements, |
| 3325 definingElement.compilationUnit.script.resourceUri); | 3390 definingElement.compilationUnit.script.resourceUri); |
| 3326 } | 3391 } |
| 3327 } | 3392 } |
| OLD | NEW |