OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 kernel.transformations.method_call; | 5 library kernel.transformations.method_call; |
6 | 6 |
7 import 'dart:math' as math; | 7 import 'dart:math' as math; |
8 | 8 |
9 import '../ast.dart'; | 9 import '../ast.dart'; |
10 import '../class_hierarchy.dart'; | 10 import '../class_hierarchy.dart'; |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 List<VariableDeclaration> originalNamedParameters, | 778 List<VariableDeclaration> originalNamedParameters, |
779 List<VariableDeclaration> newParameterDeclarations, | 779 List<VariableDeclaration> newParameterDeclarations, |
780 List<VariableDeclaration> newNamedParameterDeclarations, | 780 List<VariableDeclaration> newNamedParameterDeclarations, |
781 List<Expression> newParameterVariableGets, | 781 List<Expression> newParameterVariableGets, |
782 TreeNode newStuffParent) { | 782 TreeNode newStuffParent) { |
783 for (final orgVar in originalParameters) { | 783 for (final orgVar in originalParameters) { |
784 final variableDeclaration = new VariableDeclaration(orgVar.name, | 784 final variableDeclaration = new VariableDeclaration(orgVar.name, |
785 initializer: orgVar.initializer, | 785 initializer: orgVar.initializer, |
786 type: orgVar.type, | 786 type: orgVar.type, |
787 isFinal: orgVar.isFinal, | 787 isFinal: orgVar.isFinal, |
788 isConst: orgVar.isConst)..parent = newStuffParent; | 788 isConst: orgVar.isConst) |
| 789 ..parent = newStuffParent; |
789 variableDeclaration.initializer?.parent = variableDeclaration; | 790 variableDeclaration.initializer?.parent = variableDeclaration; |
790 newParameterDeclarations.add(variableDeclaration); | 791 newParameterDeclarations.add(variableDeclaration); |
791 orgVar.initializer = null; | 792 orgVar.initializer = null; |
792 newParameterVariableGets.add(new VariableGet(variableDeclaration)); | 793 newParameterVariableGets.add(new VariableGet(variableDeclaration)); |
793 } | 794 } |
794 | 795 |
795 // Named expressions in newParameterVariableGets should be sorted | 796 // Named expressions in newParameterVariableGets should be sorted |
796 final tmp = new List<_Pair<String, Expression>>(); | 797 final tmp = new List<_Pair<String, Expression>>(); |
797 for (final orgVar in originalNamedParameters) { | 798 for (final orgVar in originalNamedParameters) { |
798 final variableDeclaration = new VariableDeclaration(orgVar.name, | 799 final variableDeclaration = new VariableDeclaration(orgVar.name, |
799 initializer: orgVar.initializer, | 800 initializer: orgVar.initializer, |
800 type: orgVar.type, | 801 type: orgVar.type, |
801 isFinal: orgVar.isFinal, | 802 isFinal: orgVar.isFinal, |
802 isConst: orgVar.isConst)..parent = newStuffParent; | 803 isConst: orgVar.isConst) |
| 804 ..parent = newStuffParent; |
803 variableDeclaration.initializer?.parent = variableDeclaration; | 805 variableDeclaration.initializer?.parent = variableDeclaration; |
804 newNamedParameterDeclarations.add(variableDeclaration); | 806 newNamedParameterDeclarations.add(variableDeclaration); |
805 orgVar.initializer = null; | 807 orgVar.initializer = null; |
806 tmp.add(new _Pair(orgVar.name, new VariableGet(variableDeclaration))); | 808 tmp.add(new _Pair(orgVar.name, new VariableGet(variableDeclaration))); |
807 } | 809 } |
808 tmp.sort((a, b) => a.key.compareTo(b.key)); | 810 tmp.sort((a, b) => a.key.compareTo(b.key)); |
809 for (final item in tmp) { | 811 for (final item in tmp) { |
810 newParameterVariableGets.add(item.value); | 812 newParameterVariableGets.add(item.value); |
811 } | 813 } |
812 } | 814 } |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 return printStackTrace; | 1306 return printStackTrace; |
1305 } | 1307 } |
1306 } | 1308 } |
1307 | 1309 |
1308 class _Pair<K, V> { | 1310 class _Pair<K, V> { |
1309 final K key; | 1311 final K key; |
1310 final V value; | 1312 final V value; |
1311 | 1313 |
1312 _Pair(this.key, this.value); | 1314 _Pair(this.key, this.value); |
1313 } | 1315 } |
OLD | NEW |