| 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 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1693 } else if (name is String) { | 1693 } else if (name is String) { |
| 1694 push(kernelTypeFromString(name, arguments, beginToken.charOffset)); | 1694 push(kernelTypeFromString(name, arguments, beginToken.charOffset)); |
| 1695 } else { | 1695 } else { |
| 1696 internalError("Unhandled: '${name.runtimeType}'."); | 1696 internalError("Unhandled: '${name.runtimeType}'."); |
| 1697 } | 1697 } |
| 1698 } | 1698 } |
| 1699 | 1699 |
| 1700 @override | 1700 @override |
| 1701 void beginFunctionType(Token beginToken) { | 1701 void beginFunctionType(Token beginToken) { |
| 1702 debugEvent("beginFunctionType"); | 1702 debugEvent("beginFunctionType"); |
| 1703 enterFunctionTypeScope(); |
| 1704 } |
| 1705 |
| 1706 void enterFunctionTypeScope() { |
| 1703 List typeVariables = pop(); | 1707 List typeVariables = pop(); |
| 1704 enterLocalScope(scope.createNestedScope(isModifiable: false)); | 1708 enterLocalScope(scope.createNestedScope(isModifiable: false)); |
| 1705 push(typeVariables ?? NullValue.TypeVariables); | 1709 push(typeVariables ?? NullValue.TypeVariables); |
| 1706 if (typeVariables != null) { | 1710 if (typeVariables != null) { |
| 1707 ScopeBuilder scopeBuilder = new ScopeBuilder(scope); | 1711 ScopeBuilder scopeBuilder = new ScopeBuilder(scope); |
| 1708 for (KernelTypeVariableBuilder builder in typeVariables) { | 1712 for (KernelTypeVariableBuilder builder in typeVariables) { |
| 1709 String name = builder.name; | 1713 String name = builder.name; |
| 1710 KernelTypeVariableBuilder existing = scopeBuilder[name]; | 1714 KernelTypeVariableBuilder existing = scopeBuilder[name]; |
| 1711 if (existing == null) { | 1715 if (existing == null) { |
| 1712 scopeBuilder.addMember(name, builder); | 1716 scopeBuilder.addMember(name, builder); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1850 FormalParameterType kind = optional("{", beginToken) | 1854 FormalParameterType kind = optional("{", beginToken) |
| 1851 ? FormalParameterType.NAMED | 1855 ? FormalParameterType.NAMED |
| 1852 : FormalParameterType.POSITIONAL; | 1856 : FormalParameterType.POSITIONAL; |
| 1853 push(new OptionalFormals(kind, popList(count) ?? [])); | 1857 push(new OptionalFormals(kind, popList(count) ?? [])); |
| 1854 } | 1858 } |
| 1855 | 1859 |
| 1856 @override | 1860 @override |
| 1857 void beginFunctionTypedFormalParameter(Token token) { | 1861 void beginFunctionTypedFormalParameter(Token token) { |
| 1858 debugEvent("beginFunctionTypedFormalParameter"); | 1862 debugEvent("beginFunctionTypedFormalParameter"); |
| 1859 functionNestingLevel++; | 1863 functionNestingLevel++; |
| 1864 enterFunctionTypeScope(); |
| 1860 } | 1865 } |
| 1861 | 1866 |
| 1862 @override | 1867 @override |
| 1863 void endFunctionTypedFormalParameter( | 1868 void endFunctionTypedFormalParameter() { |
| 1864 Token thisKeyword, FormalParameterType kind) { | |
| 1865 debugEvent("FunctionTypedFormalParameter"); | 1869 debugEvent("FunctionTypedFormalParameter"); |
| 1866 if (inCatchClause || functionNestingLevel != 0) { | 1870 if (inCatchClause || functionNestingLevel != 0) { |
| 1867 exitLocalScope(); | 1871 exitLocalScope(); |
| 1868 } | 1872 } |
| 1869 FormalParameters formals = pop(); | 1873 FormalParameters formals = pop(); |
| 1870 ignore(Unhandled.TypeVariables); | |
| 1871 Identifier name = pop(); | |
| 1872 DartType returnType = pop(); | 1874 DartType returnType = pop(); |
| 1873 push(formals.toFunctionType(returnType)); | 1875 List<TypeParameter> typeVariables = typeVariableBuildersToKernel(pop()); |
| 1874 push(name); | 1876 FunctionType type = formals.toFunctionType(returnType, typeVariables); |
| 1877 exitLocalScope(); |
| 1878 push(type); |
| 1875 functionNestingLevel--; | 1879 functionNestingLevel--; |
| 1876 } | 1880 } |
| 1877 | 1881 |
| 1878 @override | 1882 @override |
| 1879 void handleValuedFormalParameter(Token equals, Token token) { | 1883 void handleValuedFormalParameter(Token equals, Token token) { |
| 1880 debugEvent("ValuedFormalParameter"); | 1884 debugEvent("ValuedFormalParameter"); |
| 1881 Expression initializer = popForValue(); | 1885 Expression initializer = popForValue(); |
| 1882 Identifier name = pop(); | 1886 Identifier name = pop(); |
| 1883 push(new InitializedIdentifier(name.token, initializer)); | 1887 push(new InitializedIdentifier(name.token, initializer)); |
| 1884 } | 1888 } |
| (...skipping 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3719 if (starToken == null) { | 3723 if (starToken == null) { |
| 3720 return AsyncMarker.Async; | 3724 return AsyncMarker.Async; |
| 3721 } else { | 3725 } else { |
| 3722 assert(identical(starToken.stringValue, "*")); | 3726 assert(identical(starToken.stringValue, "*")); |
| 3723 return AsyncMarker.AsyncStar; | 3727 return AsyncMarker.AsyncStar; |
| 3724 } | 3728 } |
| 3725 } else { | 3729 } else { |
| 3726 return internalError("Unknown async modifier: $asyncToken"); | 3730 return internalError("Unknown async modifier: $asyncToken"); |
| 3727 } | 3731 } |
| 3728 } | 3732 } |
| OLD | NEW |