Chromium Code Reviews| 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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 int optionalParameterCount(Compiler compiler) { | 612 int optionalParameterCount(Compiler compiler) { |
| 613 return computeParameters(compiler).optionalParameterCount; | 613 return computeParameters(compiler).optionalParameterCount; |
| 614 } | 614 } |
| 615 | 615 |
| 616 int parameterCount(Compiler compiler) { | 616 int parameterCount(Compiler compiler) { |
| 617 return computeParameters(compiler).parameterCount; | 617 return computeParameters(compiler).parameterCount; |
| 618 } | 618 } |
| 619 | 619 |
| 620 FunctionType computeType(Compiler compiler) { | 620 FunctionType computeType(Compiler compiler) { |
| 621 if (type != null) return type; | 621 if (type != null) return type; |
| 622 FunctionParameters parameters = computeParameters(compiler); | 622 return compiler.withCurrentElement(this, () { |
|
kasperl
2012/04/23 11:45:45
Would it be possible to add a regression test case
| |
| 623 Types types = compiler.types; | 623 FunctionParameters parameters = computeParameters(compiler); |
| 624 FunctionExpression node = | 624 Types types = compiler.types; |
| 625 compiler.parser.measure(() => parseNode(compiler)); | 625 FunctionExpression node = |
| 626 Type returnType = getType(node.returnType, compiler, getLibrary()); | 626 compiler.parser.measure(() => parseNode(compiler)); |
| 627 if (returnType === null) returnType = types.dynamicType; | 627 Type returnType = getType(node.returnType, compiler, getLibrary()); |
| 628 if (returnType === null) returnType = types.dynamicType; | |
| 628 | 629 |
| 629 LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>(); | 630 LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>(); |
| 630 for (Link<Element> link = parameters.requiredParameters; | 631 for (Link<Element> link = parameters.requiredParameters; |
| 631 !link.isEmpty(); | 632 !link.isEmpty(); |
| 632 link = link.tail) { | 633 link = link.tail) { |
| 633 parameterTypes.addLast(link.head.computeType(compiler)); | 634 parameterTypes.addLast(link.head.computeType(compiler)); |
| 634 } | 635 } |
| 635 type = new FunctionType(returnType, parameterTypes.toLink(), this); | 636 type = new FunctionType(returnType, parameterTypes.toLink(), this); |
| 636 return type; | 637 return type; |
| 638 }); | |
| 637 } | 639 } |
| 638 | 640 |
| 639 Node parseNode(DiagnosticListener listener) => cachedNode; | 641 Node parseNode(DiagnosticListener listener) => cachedNode; |
| 640 | 642 |
| 641 Token position() => cachedNode.getBeginToken(); | 643 Token position() => cachedNode.getBeginToken(); |
| 642 } | 644 } |
| 643 | 645 |
| 644 class ConstructorBodyElement extends FunctionElement { | 646 class ConstructorBodyElement extends FunctionElement { |
| 645 FunctionElement constructor; | 647 FunctionElement constructor; |
| 646 | 648 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1027 final Node node; | 1029 final Node node; |
| 1028 Type bound; | 1030 Type bound; |
| 1029 Type type; | 1031 Type type; |
| 1030 TypeVariableElement(name, Element enclosing, this.node, this.type, | 1032 TypeVariableElement(name, Element enclosing, this.node, this.type, |
| 1031 [this.bound]) | 1033 [this.bound]) |
| 1032 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 1034 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 1033 Type computeType(compiler) => type; | 1035 Type computeType(compiler) => type; |
| 1034 Node parseNode(compiler) => node; | 1036 Node parseNode(compiler) => node; |
| 1035 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1037 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1036 } | 1038 } |
| OLD | NEW |