| 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 #library('elements'); | 5 #library('elements'); |
| 6 | 6 |
| 7 #import('dart:uri'); | 7 #import('dart:uri'); |
| 8 | 8 |
| 9 #import('../tree/tree.dart'); | 9 #import('../tree/tree.dart'); |
| 10 #import('../scanner/scannerlib.dart'); | 10 #import('../scanner/scannerlib.dart'); |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 Type computeType(Compiler compiler) => compiler.types.dynamicType; | 484 Type computeType(Compiler compiler) => compiler.types.dynamicType; |
| 485 | 485 |
| 486 Token position() => firstPosition; | 486 Token position() => firstPosition; |
| 487 | 487 |
| 488 PrefixElement cloneTo(Element enclosing, DiagnosticListener listener) { | 488 PrefixElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| 489 return new PrefixElement(name, enclosing, firstPosition); | 489 return new PrefixElement(name, enclosing, firstPosition); |
| 490 } | 490 } |
| 491 } | 491 } |
| 492 | 492 |
| 493 class TypedefElement extends Element implements TypeDeclarationElement { | 493 class TypedefElement extends Element implements TypeDeclarationElement { |
| 494 Type cachedType; | |
| 495 Typedef cachedNode; | 494 Typedef cachedNode; |
| 495 TypedefType cachedType; |
| 496 Type alias; |
| 497 |
| 498 bool isResolved = false; |
| 499 bool isBeingResolved = false; |
| 496 | 500 |
| 497 TypedefElement(SourceString name, Element enclosing) | 501 TypedefElement(SourceString name, Element enclosing) |
| 498 : super(name, ElementKind.TYPEDEF, enclosing); | 502 : super(name, ElementKind.TYPEDEF, enclosing); |
| 499 | 503 |
| 500 Type computeType(Compiler compiler) { | 504 /** |
| 505 * Function signature for a typedef of a function type. The signature is |
| 506 * kept to provide full information about parameter names through the mirror |
| 507 * system. |
| 508 * |
| 509 * The [functionSignature] is not available until the typedef element has been |
| 510 * resolved. |
| 511 */ |
| 512 FunctionSignature functionSignature; |
| 513 |
| 514 TypedefType computeType(Compiler compiler) { |
| 501 if (cachedType !== null) return cachedType; | 515 if (cachedType !== null) return cachedType; |
| 502 cachedType = new FunctionType(null, null, this); | 516 Typedef node = parseNode(compiler); |
| 503 cachedType.initializeFrom( | 517 Link<Type> parameters = |
| 504 compiler.computeFunctionType(this, compiler.resolveTypedef(this))); | 518 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); |
| 519 cachedType = new TypedefType(this, parameters); |
| 520 compiler.resolveTypedef(this); |
| 505 return cachedType; | 521 return cachedType; |
| 506 } | 522 } |
| 507 | 523 |
| 508 Link<Type> get typeVariables() => const EmptyLink<Type>(); | 524 Link<Type> get typeVariables() => cachedType.typeArguments; |
| 509 | 525 |
| 510 Scope buildScope() => | 526 Scope buildScope() => |
| 511 new TypeDeclarationScope(enclosingElement.buildScope(), this); | 527 new TypeDeclarationScope(enclosingElement.buildScope(), this); |
| 512 | 528 |
| 513 TypedefElement cloneTo(Element enclosing, DiagnosticListener listener) { | 529 TypedefElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| 514 TypedefElement result = new TypedefElement(name, enclosing); | 530 TypedefElement result = new TypedefElement(name, enclosing); |
| 515 return result; | 531 return result; |
| 516 } | 532 } |
| 517 } | 533 } |
| 518 | 534 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 } | 667 } |
| 652 assert(type != null); | 668 assert(type != null); |
| 653 return type; | 669 return type; |
| 654 } | 670 } |
| 655 | 671 |
| 656 Token position() => cachedNode.getBeginToken(); | 672 Token position() => cachedNode.getBeginToken(); |
| 657 | 673 |
| 658 VariableListElement cloneTo(Element enclosing, DiagnosticListener listener) { | 674 VariableListElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| 659 VariableListElement result; | 675 VariableListElement result; |
| 660 if (cachedNode !== null) { | 676 if (cachedNode !== null) { |
| 661 result = new VariableListElement(cachedNode, kind, enclosing); | 677 result = new VariableListElement.node(cachedNode, kind, enclosing); |
| 662 } else { | 678 } else { |
| 663 result = new VariableListElement(kind, modifiers, enclosing); | 679 result = new VariableListElement(kind, modifiers, enclosing); |
| 664 } | 680 } |
| 665 return result; | 681 return result; |
| 666 } | 682 } |
| 667 } | 683 } |
| 668 | 684 |
| 669 class ForeignElement extends Element { | 685 class ForeignElement extends Element { |
| 670 ForeignElement(SourceString name, ContainerElement enclosingElement) | 686 ForeignElement(SourceString name, ContainerElement enclosingElement) |
| 671 : super(name, ElementKind.FOREIGN, enclosingElement); | 687 : super(name, ElementKind.FOREIGN, enclosingElement); |
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 1498 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 1483 | 1499 |
| 1484 TypeVariableType computeType(compiler) => type; | 1500 TypeVariableType computeType(compiler) => type; |
| 1485 | 1501 |
| 1486 Node parseNode(compiler) => cachedNode; | 1502 Node parseNode(compiler) => cachedNode; |
| 1487 | 1503 |
| 1488 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1504 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1489 | 1505 |
| 1490 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { | 1506 TypeVariableElement cloneTo(Element enclosing, DiagnosticListener listener) { |
| 1491 TypeVariableElement result = | 1507 TypeVariableElement result = |
| 1492 new TypeVariableElement(name, enclosing, node, type, bound); | 1508 new TypeVariableElement(name, enclosing, cachedNode, type, bound); |
| 1493 return result; | 1509 return result; |
| 1494 } | 1510 } |
| 1495 } | 1511 } |
| OLD | NEW |