| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.semantics_visitor; | 5 part of dart2js.semantics_visitor; |
| 6 | 6 |
| 7 enum SendStructureKind { | 7 enum SendStructureKind { |
| 8 GET, | 8 GET, |
| 9 SET, | 9 SET, |
| 10 INVOKE, | 10 INVOKE, |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 } | 393 } |
| 394 } else if (element.impliesType) { | 394 } else if (element.impliesType) { |
| 395 // TODO(johnniwinther): Provide an [ErroneousElement]. | 395 // TODO(johnniwinther): Provide an [ErroneousElement]. |
| 396 // This happens for code like `C.this`. | 396 // This happens for code like `C.this`. |
| 397 return new StaticAccess.unresolved(null); | 397 return new StaticAccess.unresolved(null); |
| 398 } else { | 398 } else { |
| 399 return handleStaticallyResolvedAccess(node, element, getter); | 399 return handleStaticallyResolvedAccess(node, element, getter); |
| 400 } | 400 } |
| 401 } | 401 } |
| 402 } | 402 } |
| 403 |
| 404 ConstructorAccessSemantics computeConstructorAccessSemantics( |
| 405 ConstructorElement constructor, |
| 406 DartType type) { |
| 407 if (constructor.isErroneous) { |
| 408 return new ConstructorAccessSemantics( |
| 409 ConstructorAccessKind.ERRONEOUS, constructor, type); |
| 410 } else if (constructor.isRedirectingFactory) { |
| 411 ConstructorElement effectiveTarget = constructor.effectiveTarget; |
| 412 if (effectiveTarget == constructor || |
| 413 effectiveTarget.isErroneous) { |
| 414 return new ConstructorAccessSemantics( |
| 415 ConstructorAccessKind.ERRONEOUS_REDIRECTING_FACTORY, |
| 416 constructor, |
| 417 type); |
| 418 } |
| 419 ConstructorAccessSemantics effectiveTargetSemantics = |
| 420 computeConstructorAccessSemantics( |
| 421 effectiveTarget, |
| 422 constructor.computeEffectiveTargetType(type)); |
| 423 if (effectiveTargetSemantics.isErroneous) { |
| 424 return new RedirectingFactoryConstructorAccessSemantics( |
| 425 ConstructorAccessKind.ERRONEOUS_REDIRECTING_FACTORY, |
| 426 constructor, |
| 427 type, |
| 428 effectiveTargetSemantics); |
| 429 } |
| 430 return new RedirectingFactoryConstructorAccessSemantics( |
| 431 ConstructorAccessKind.REDIRECTING_FACTORY, |
| 432 constructor, |
| 433 type, |
| 434 effectiveTargetSemantics); |
| 435 } else if (constructor.isFactoryConstructor) { |
| 436 return new ConstructorAccessSemantics( |
| 437 ConstructorAccessKind.FACTORY, constructor, type); |
| 438 } else if (constructor.isRedirectingGenerative) { |
| 439 if (constructor.enclosingClass.isAbstract) { |
| 440 return new ConstructorAccessSemantics( |
| 441 ConstructorAccessKind.ABSTRACT, constructor, type); |
| 442 } |
| 443 return new ConstructorAccessSemantics( |
| 444 ConstructorAccessKind.REDIRECTING_GENERATIVE, constructor, type); |
| 445 } else if (constructor.enclosingClass.isAbstract) { |
| 446 return new ConstructorAccessSemantics( |
| 447 ConstructorAccessKind.ABSTRACT, constructor, type); |
| 448 } else { |
| 449 return new ConstructorAccessSemantics( |
| 450 ConstructorAccessKind.GENERATIVE, constructor, type); |
| 451 } |
| 452 } |
| 453 |
| 454 NewStructure computeNewStructure(NewExpression node) { |
| 455 if (node.isConst) { |
| 456 return new ConstInvokeStructure(elements.getConstant(node)); |
| 457 } |
| 458 Element element = elements[node.send]; |
| 459 Selector selector = elements.getSelector(node.send); |
| 460 DartType type = elements.getType(node); |
| 461 |
| 462 ConstructorAccessSemantics constructorAccessSemantics = |
| 463 computeConstructorAccessSemantics(element, type); |
| 464 return new NewInvokeStructure(constructorAccessSemantics, selector); |
| 465 } |
| 403 } | 466 } |
| 404 | 467 |
| OLD | NEW |