| 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 'package:front_end/src/fasta/parser/parser.dart' show | 7 import 'package:front_end/src/fasta/parser/parser.dart' show |
| 8 FormalParameterType, | 8 FormalParameterType, |
| 9 optional; | 9 optional; |
| 10 | 10 |
| (...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 VariableDeclaration variable; | 910 VariableDeclaration variable; |
| 911 if (node is VariableDeclaration) { | 911 if (node is VariableDeclaration) { |
| 912 variable = node; | 912 variable = node; |
| 913 } else if (node is Identifier) { | 913 } else if (node is Identifier) { |
| 914 variable = new VariableDeclaration(node.name); | 914 variable = new VariableDeclaration(node.name); |
| 915 } else { | 915 } else { |
| 916 internalError("unhandled identifier: ${node.runtimeType}"); | 916 internalError("unhandled identifier: ${node.runtimeType}"); |
| 917 } | 917 } |
| 918 push(variable); | 918 push(variable); |
| 919 scope[variable.name] = new KernelVariableBuilder(variable, | 919 scope[variable.name] = new KernelVariableBuilder(variable, |
| 920 // TODO(ahe): This should be `member ?? classBuilder ?? part`, but we | 920 member ?? classBuilder ?? library, uri); |
| 921 // don't have an object representing the current part. | |
| 922 member ?? classBuilder); | |
| 923 } | 921 } |
| 924 | 922 |
| 925 @override | 923 @override |
| 926 void endVariablesDeclaration(int count, Token endToken) { | 924 void endVariablesDeclaration(int count, Token endToken) { |
| 927 debugEvent("VariablesDeclaration"); | 925 debugEvent("VariablesDeclaration"); |
| 928 List<VariableDeclaration> variables = popList(count); | 926 List<VariableDeclaration> variables = popList(count); |
| 929 DartType type = pop(); | 927 DartType type = pop(); |
| 930 int modifiers = Modifier.validate(pop()); | 928 int modifiers = Modifier.validate(pop()); |
| 931 bool isConst = (modifiers & constMask) != 0; | 929 bool isConst = (modifiers & constMask) != 0; |
| 932 bool isFinal = (modifiers & finalMask) != 0; | 930 bool isFinal = (modifiers & finalMask) != 0; |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1754 | 1752 |
| 1755 @override | 1753 @override |
| 1756 void endFunctionName(Token token) { | 1754 void endFunctionName(Token token) { |
| 1757 debugEvent("FunctionName"); | 1755 debugEvent("FunctionName"); |
| 1758 Identifier name = pop(); | 1756 Identifier name = pop(); |
| 1759 VariableDeclaration variable = new VariableDeclaration( | 1757 VariableDeclaration variable = new VariableDeclaration( |
| 1760 name.name, isFinal: true); | 1758 name.name, isFinal: true); |
| 1761 push(new FunctionDeclaration(variable, | 1759 push(new FunctionDeclaration(variable, |
| 1762 new FunctionNode(new InvalidStatement()))); | 1760 new FunctionNode(new InvalidStatement()))); |
| 1763 scope[variable.name] = new KernelVariableBuilder(variable, | 1761 scope[variable.name] = new KernelVariableBuilder(variable, |
| 1764 // TODO(ahe): This should be `member ?? classBuilder ?? part`, but we | 1762 member ?? classBuilder ?? library, uri); |
| 1765 // don't have an object representing the current part. | |
| 1766 member ?? classBuilder); | |
| 1767 enterLocalScope(); | 1763 enterLocalScope(); |
| 1768 } | 1764 } |
| 1769 | 1765 |
| 1770 @override | 1766 @override |
| 1771 void beginFunction(Token token) { | 1767 void beginFunction(Token token) { |
| 1772 debugEvent("beginFunction"); | 1768 debugEvent("beginFunction"); |
| 1773 functionNestingLevel++; | 1769 functionNestingLevel++; |
| 1774 } | 1770 } |
| 1775 | 1771 |
| 1776 @override | 1772 @override |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2655 } | 2651 } |
| 2656 return new FunctionType(positionalParameters, returnType, | 2652 return new FunctionType(positionalParameters, returnType, |
| 2657 namedParameters: namedParameters, | 2653 namedParameters: namedParameters, |
| 2658 requiredParameterCount: requiredParameterCount); | 2654 requiredParameterCount: requiredParameterCount); |
| 2659 } | 2655 } |
| 2660 | 2656 |
| 2661 Scope computeFormalParameterScope(Scope parent, Builder builder) { | 2657 Scope computeFormalParameterScope(Scope parent, Builder builder) { |
| 2662 if (required.length == 0 && optional == null) return parent; | 2658 if (required.length == 0 && optional == null) return parent; |
| 2663 Map<String, Builder> local = <String, Builder>{}; | 2659 Map<String, Builder> local = <String, Builder>{}; |
| 2664 for (VariableDeclaration parameter in required) { | 2660 for (VariableDeclaration parameter in required) { |
| 2665 local[parameter.name] = new KernelVariableBuilder(parameter, builder); | 2661 local[parameter.name] = |
| 2662 new KernelVariableBuilder(parameter, builder, builder.fileUri); |
| 2666 } | 2663 } |
| 2667 if (optional != null) { | 2664 if (optional != null) { |
| 2668 for (VariableDeclaration parameter in optional.formals) { | 2665 for (VariableDeclaration parameter in optional.formals) { |
| 2669 local[parameter.name] = new KernelVariableBuilder(parameter, builder); | 2666 local[parameter.name] = |
| 2667 new KernelVariableBuilder(parameter, builder, builder.fileUri); |
| 2670 } | 2668 } |
| 2671 } | 2669 } |
| 2672 return new Scope(local, parent, isModifiable: false); | 2670 return new Scope(local, parent, isModifiable: false); |
| 2673 } | 2671 } |
| 2674 } | 2672 } |
| 2675 | 2673 |
| 2676 /// Returns a block like this: | 2674 /// Returns a block like this: |
| 2677 /// | 2675 /// |
| 2678 /// { | 2676 /// { |
| 2679 /// statement; | 2677 /// statement; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2704 } else if (node is TypeDeclarationBuilder) { | 2702 } else if (node is TypeDeclarationBuilder) { |
| 2705 return node.name; | 2703 return node.name; |
| 2706 } else if (node is PrefixBuilder) { | 2704 } else if (node is PrefixBuilder) { |
| 2707 return node.name; | 2705 return node.name; |
| 2708 } else if (node is ThisPropertyAccessor) { | 2706 } else if (node is ThisPropertyAccessor) { |
| 2709 return node.name.name; | 2707 return node.name.name; |
| 2710 } else { | 2708 } else { |
| 2711 return internalError("Unhandled: ${node.runtimeType}"); | 2709 return internalError("Unhandled: ${node.runtimeType}"); |
| 2712 } | 2710 } |
| 2713 } | 2711 } |
| OLD | NEW |