| 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 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 | 938 |
| 939 // TODO(johnniwinther): [FunctionSignature] should be merged with | 939 // TODO(johnniwinther): [FunctionSignature] should be merged with |
| 940 // [FunctionType]. | 940 // [FunctionType]. |
| 941 class FunctionSignature { | 941 class FunctionSignature { |
| 942 final Link<Element> requiredParameters; | 942 final Link<Element> requiredParameters; |
| 943 final Link<Element> optionalParameters; | 943 final Link<Element> optionalParameters; |
| 944 final DartType returnType; | 944 final DartType returnType; |
| 945 final int requiredParameterCount; | 945 final int requiredParameterCount; |
| 946 final int optionalParameterCount; | 946 final int optionalParameterCount; |
| 947 final bool optionalParametersAreNamed; | 947 final bool optionalParametersAreNamed; |
| 948 |
| 949 List<Element> _orderedOptionalParameters; |
| 950 |
| 948 FunctionSignature(this.requiredParameters, | 951 FunctionSignature(this.requiredParameters, |
| 949 this.optionalParameters, | 952 this.optionalParameters, |
| 950 this.requiredParameterCount, | 953 this.requiredParameterCount, |
| 951 this.optionalParameterCount, | 954 this.optionalParameterCount, |
| 952 this.optionalParametersAreNamed, | 955 this.optionalParametersAreNamed, |
| 953 this.returnType); | 956 this.returnType); |
| 954 | 957 |
| 955 void forEachRequiredParameter(void function(Element parameter)) { | 958 void forEachRequiredParameter(void function(Element parameter)) { |
| 956 for (Link<Element> link = requiredParameters; | 959 for (Link<Element> link = requiredParameters; |
| 957 !link.isEmpty(); | 960 !link.isEmpty(); |
| 958 link = link.tail) { | 961 link = link.tail) { |
| 959 function(link.head); | 962 function(link.head); |
| 960 } | 963 } |
| 961 } | 964 } |
| 962 | 965 |
| 963 void forEachOptionalParameter(void function(Element parameter)) { | 966 void forEachOptionalParameter(void function(Element parameter)) { |
| 964 for (Link<Element> link = optionalParameters; | 967 for (Link<Element> link = optionalParameters; |
| 965 !link.isEmpty(); | 968 !link.isEmpty(); |
| 966 link = link.tail) { | 969 link = link.tail) { |
| 967 function(link.head); | 970 function(link.head); |
| 968 } | 971 } |
| 969 } | 972 } |
| 970 | 973 |
| 974 List<Element> get orderedOptionalParameters { |
| 975 if (_orderedOptionalParameters != null) return _orderedOptionalParameters; |
| 976 List<Element> list = new List<Element>.from(optionalParameters); |
| 977 if (optionalParametersAreNamed) { |
| 978 list.sort((Element a, Element b) { |
| 979 return a.name.slowToString().compareTo(b.name.slowToString()); |
| 980 }); |
| 981 } |
| 982 _orderedOptionalParameters = list; |
| 983 return list; |
| 984 } |
| 985 |
| 971 void forEachParameter(void function(Element parameter)) { | 986 void forEachParameter(void function(Element parameter)) { |
| 972 forEachRequiredParameter(function); | 987 forEachRequiredParameter(function); |
| 973 forEachOptionalParameter(function); | 988 forEachOptionalParameter(function); |
| 974 } | 989 } |
| 975 | 990 |
| 991 void orderedForEachParameter(void function(Element parameter)) { |
| 992 forEachRequiredParameter(function); |
| 993 orderedOptionalParameters.forEach(function); |
| 994 } |
| 995 |
| 976 int get parameterCount => requiredParameterCount + optionalParameterCount; | 996 int get parameterCount => requiredParameterCount + optionalParameterCount; |
| 977 } | 997 } |
| 978 | 998 |
| 979 class FunctionElement extends Element { | 999 class FunctionElement extends Element { |
| 980 FunctionExpression cachedNode; | 1000 FunctionExpression cachedNode; |
| 981 DartType type; | 1001 DartType type; |
| 982 final Modifiers modifiers; | 1002 final Modifiers modifiers; |
| 983 | 1003 |
| 984 FunctionSignature functionSignature; | 1004 FunctionSignature functionSignature; |
| 985 | 1005 |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1811 | 1831 |
| 1812 MetadataAnnotation ensureResolved(Compiler compiler) { | 1832 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1813 if (resolutionState == STATE_NOT_STARTED) { | 1833 if (resolutionState == STATE_NOT_STARTED) { |
| 1814 compiler.resolver.resolveMetadataAnnotation(this); | 1834 compiler.resolver.resolveMetadataAnnotation(this); |
| 1815 } | 1835 } |
| 1816 return this; | 1836 return this; |
| 1817 } | 1837 } |
| 1818 | 1838 |
| 1819 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1839 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1820 } | 1840 } |
| OLD | NEW |