OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 fasta.body_builder; | 5 library fasta.body_builder; |
6 | 6 |
7 import '../fasta_codes.dart' | 7 import '../fasta_codes.dart' |
8 show | 8 show |
9 FastaMessage, | 9 FastaMessage, |
10 codeConstFieldWithoutInitializer, | 10 codeConstFieldWithoutInitializer, |
(...skipping 2023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2034 return throwNoSuchMethodError(new NullLiteral()..fileOffset = charOffset, | 2034 return throwNoSuchMethodError(new NullLiteral()..fileOffset = charOffset, |
2035 target.name.name, arguments, charOffset); | 2035 target.name.name, arguments, charOffset); |
2036 } | 2036 } |
2037 if (target is Constructor) { | 2037 if (target is Constructor) { |
2038 if (isConst && !target.isConst) { | 2038 if (isConst && !target.isConst) { |
2039 return buildCompileTimeError("Not a const constructor.", charOffset); | 2039 return buildCompileTimeError("Not a const constructor.", charOffset); |
2040 } | 2040 } |
2041 return new KernelConstructorInvocation(target, initialTarget, arguments, | 2041 return new KernelConstructorInvocation(target, initialTarget, arguments, |
2042 isConst: isConst) | 2042 isConst: isConst) |
2043 ..fileOffset = charOffset; | 2043 ..fileOffset = charOffset; |
2044 } else if (target is Procedure && target.kind == ProcedureKind.Factory) { | |
2045 return new KernelFactoryConstructorInvocation( | |
2046 target, initialTarget, arguments, | |
2047 isConst: isConst) | |
2048 ..fileOffset = charOffset; | |
2049 } else { | 2044 } else { |
2050 Procedure factory = target; | 2045 Procedure procedure = target; |
2051 if (isConst && !factory.isConst) { | 2046 if (isConst && !procedure.isConst) { |
2052 return buildCompileTimeError("Not a const factory.", charOffset); | 2047 return buildCompileTimeError("Not a const factory.", charOffset); |
| 2048 } else if (procedure.isFactory) { |
| 2049 return new KernelFactoryConstructorInvocation( |
| 2050 target, initialTarget, arguments, |
| 2051 isConst: isConst) |
| 2052 ..fileOffset = charOffset; |
| 2053 } else { |
| 2054 return new KernelStaticInvocation(target, arguments, isConst: isConst) |
| 2055 ..fileOffset = charOffset; |
2053 } | 2056 } |
2054 return new KernelStaticInvocation(target, arguments, isConst: isConst) | |
2055 ..fileOffset = charOffset; | |
2056 } | 2057 } |
2057 } | 2058 } |
2058 | 2059 |
2059 @override | 2060 @override |
2060 bool checkArguments(FunctionNode function, Arguments arguments, | 2061 bool checkArguments(FunctionNode function, Arguments arguments, |
2061 List<TypeParameter> typeParameters) { | 2062 List<TypeParameter> typeParameters) { |
2062 if (arguments.positional.length < function.requiredParameterCount || | 2063 if (arguments.positional.length < function.requiredParameterCount || |
2063 arguments.positional.length > function.positionalParameters.length) { | 2064 arguments.positional.length > function.positionalParameters.length) { |
2064 return false; | 2065 return false; |
2065 } | 2066 } |
(...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3551 if (starToken == null) { | 3552 if (starToken == null) { |
3552 return AsyncMarker.Async; | 3553 return AsyncMarker.Async; |
3553 } else { | 3554 } else { |
3554 assert(identical(starToken.stringValue, "*")); | 3555 assert(identical(starToken.stringValue, "*")); |
3555 return AsyncMarker.AsyncStar; | 3556 return AsyncMarker.AsyncStar; |
3556 } | 3557 } |
3557 } else { | 3558 } else { |
3558 return internalError("Unknown async modifier: $asyncToken"); | 3559 return internalError("Unknown async modifier: $asyncToken"); |
3559 } | 3560 } |
3560 } | 3561 } |
OLD | NEW |