| 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('../tree/tree.dart'); | 7 #import('../tree/tree.dart'); |
| 8 #import('../scanner/scannerlib.dart'); | 8 #import('../scanner/scannerlib.dart'); |
| 9 #import('../leg.dart'); // TODO(karlklose): we only need type. | 9 #import('../leg.dart'); // TODO(karlklose): we only need type. |
| 10 #import('../util/util.dart'); | 10 #import('../util/util.dart'); |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 Compiler compiler, | 487 Compiler compiler, |
| 488 LibraryElement library) { | 488 LibraryElement library) { |
| 489 // TODO(karlklose,ngeoffray): This method should be removed and the | 489 // TODO(karlklose,ngeoffray): This method should be removed and the |
| 490 // information should be computed by the resolver. | 490 // information should be computed by the resolver. |
| 491 | 491 |
| 492 if (typeAnnotation == null || typeAnnotation.typeName == null) { | 492 if (typeAnnotation == null || typeAnnotation.typeName == null) { |
| 493 return compiler.types.dynamicType; | 493 return compiler.types.dynamicType; |
| 494 } | 494 } |
| 495 Identifier identifier = typeAnnotation.typeName.asIdentifier(); | 495 Identifier identifier = typeAnnotation.typeName.asIdentifier(); |
| 496 if (identifier === null) { | 496 if (identifier === null) { |
| 497 compiler.reportWarning(typeAnnotation.typeName, | 497 compiler.reportWarning( |
| 498 'library prefixes not handled'); | 498 typeAnnotation.typeName, |
| 499 new ResolutionWarning(MessageKind.GENERIC, |
| 500 ['library prefixes not handled'])); |
| 499 return compiler.types.dynamicType; | 501 return compiler.types.dynamicType; |
| 500 } | 502 } |
| 501 SourceString name = identifier.source; | 503 SourceString name = identifier.source; |
| 502 Element element = library.find(name); | 504 Element element = library.find(name); |
| 503 if (element !== null) { | 505 if (element !== null) { |
| 504 if (element.isTypedef()) { | 506 if (element.isTypedef()) { |
| 505 // TODO(ngeoffray): This is a hack to help us get support for the | 507 // TODO(ngeoffray): This is a hack to help us get support for the |
| 506 // DOM library. | 508 // DOM library. |
| 507 // TODO(ngeoffray): The list of types for the argument is wrong. | 509 // TODO(ngeoffray): The list of types for the argument is wrong. |
| 508 return new FunctionType(compiler.types.dynamicType, | 510 return new FunctionType(compiler.types.dynamicType, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 int optionalParameterCount(Compiler compiler) { | 614 int optionalParameterCount(Compiler compiler) { |
| 613 return computeParameters(compiler).optionalParameterCount; | 615 return computeParameters(compiler).optionalParameterCount; |
| 614 } | 616 } |
| 615 | 617 |
| 616 int parameterCount(Compiler compiler) { | 618 int parameterCount(Compiler compiler) { |
| 617 return computeParameters(compiler).parameterCount; | 619 return computeParameters(compiler).parameterCount; |
| 618 } | 620 } |
| 619 | 621 |
| 620 FunctionType computeType(Compiler compiler) { | 622 FunctionType computeType(Compiler compiler) { |
| 621 if (type != null) return type; | 623 if (type != null) return type; |
| 622 FunctionParameters parameters = computeParameters(compiler); | 624 return compiler.withCurrentElement(this, () { |
| 623 Types types = compiler.types; | 625 FunctionParameters parameters = computeParameters(compiler); |
| 624 FunctionExpression node = | 626 Types types = compiler.types; |
| 625 compiler.parser.measure(() => parseNode(compiler)); | 627 FunctionExpression node = |
| 626 Type returnType = getType(node.returnType, compiler, getLibrary()); | 628 compiler.parser.measure(() => parseNode(compiler)); |
| 627 if (returnType === null) returnType = types.dynamicType; | 629 Type returnType = getType(node.returnType, compiler, getLibrary()); |
| 630 if (returnType === null) returnType = types.dynamicType; |
| 628 | 631 |
| 629 LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>(); | 632 LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>(); |
| 630 for (Link<Element> link = parameters.requiredParameters; | 633 for (Link<Element> link = parameters.requiredParameters; |
| 631 !link.isEmpty(); | 634 !link.isEmpty(); |
| 632 link = link.tail) { | 635 link = link.tail) { |
| 633 parameterTypes.addLast(link.head.computeType(compiler)); | 636 parameterTypes.addLast(link.head.computeType(compiler)); |
| 634 } | 637 } |
| 635 type = new FunctionType(returnType, parameterTypes.toLink(), this); | 638 type = new FunctionType(returnType, parameterTypes.toLink(), this); |
| 636 return type; | 639 return type; |
| 640 }); |
| 637 } | 641 } |
| 638 | 642 |
| 639 Node parseNode(DiagnosticListener listener) => cachedNode; | 643 Node parseNode(DiagnosticListener listener) => cachedNode; |
| 640 | 644 |
| 641 Token position() => cachedNode.getBeginToken(); | 645 Token position() => cachedNode.getBeginToken(); |
| 642 } | 646 } |
| 643 | 647 |
| 644 class ConstructorBodyElement extends FunctionElement { | 648 class ConstructorBodyElement extends FunctionElement { |
| 645 FunctionElement constructor; | 649 FunctionElement constructor; |
| 646 | 650 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 final Node node; | 1031 final Node node; |
| 1028 Type bound; | 1032 Type bound; |
| 1029 Type type; | 1033 Type type; |
| 1030 TypeVariableElement(name, Element enclosing, this.node, this.type, | 1034 TypeVariableElement(name, Element enclosing, this.node, this.type, |
| 1031 [this.bound]) | 1035 [this.bound]) |
| 1032 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 1036 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 1033 Type computeType(compiler) => type; | 1037 Type computeType(compiler) => type; |
| 1034 Node parseNode(compiler) => node; | 1038 Node parseNode(compiler) => node; |
| 1035 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1039 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1036 } | 1040 } |
| OLD | NEW |