| 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 kernel.transformations.closure.converter; | 5 library kernel.transformations.closure.converter; |
| 6 | 6 |
| 7 import '../../ast.dart' | 7 import '../../ast.dart' |
| 8 show | 8 show |
| 9 Arguments, | 9 Arguments, |
| 10 Block, | 10 Block, |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 parent.body = initializerExpression; | 225 parent.body = initializerExpression; |
| 226 } else if (parent is FieldInitializer) { | 226 } else if (parent is FieldInitializer) { |
| 227 parent.value = initializerExpression; | 227 parent.value = initializerExpression; |
| 228 } else { | 228 } else { |
| 229 throw "Found unexpected node '${node.runtimeType}, expected a 'Let' " | 229 throw "Found unexpected node '${node.runtimeType}, expected a 'Let' " |
| 230 "or a 'FieldInitializer'."; | 230 "or a 'FieldInitializer'."; |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 rewriter = null; | 234 rewriter = null; |
| 235 context = null; |
| 235 // Transform constructor body. | 236 // Transform constructor body. |
| 236 FunctionNode function = node.function; | 237 FunctionNode function = node.function; |
| 237 if (function.body != null && function.body is! EmptyStatement) { | 238 if (function.body != null && function.body is! EmptyStatement) { |
| 238 setupContextForFunctionBody(function); | 239 setupContextForFunctionBody(function); |
| 239 VariableDeclaration self = thisAccess[currentMemberFunction]; | 240 VariableDeclaration self = thisAccess[currentMemberFunction]; |
| 240 if (self != null) { | 241 if (self != null) { |
| 241 context.extend(self, new ThisExpression()); | 242 context.extend(self, new ThisExpression()); |
| 242 } | 243 } |
| 243 node.function.accept(this); | 244 node.function.accept(this); |
| 244 resetContext(); | 245 resetContext(); |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 null, node.target, contextVariable, new NullLiteral()); | 638 null, node.target, contextVariable, new NullLiteral()); |
| 638 expression.transformChildren(this); | 639 expression.transformChildren(this); |
| 639 return expression; | 640 return expression; |
| 640 } | 641 } |
| 641 return super.visitStaticGet(node); | 642 return super.visitStaticGet(node); |
| 642 } | 643 } |
| 643 | 644 |
| 644 TreeNode visitPropertyGet(PropertyGet node) { | 645 TreeNode visitPropertyGet(PropertyGet node) { |
| 645 Name tearOffName = tearOffGetterNames[node.name]; | 646 Name tearOffName = tearOffGetterNames[node.name]; |
| 646 if (tearOffName != null) { | 647 if (tearOffName != null) { |
| 647 MethodInvocation replacement = new MethodInvocation( | 648 PropertyGet replacement = new PropertyGet(node.receiver, tearOffName); |
| 648 node.receiver, tearOffName, new Arguments(<Expression>[])); | 649 return super.visitPropertyGet(replacement); |
| 649 return super.visitMethodInvocation(replacement); | |
| 650 } | 650 } |
| 651 return super.visitPropertyGet(node); | 651 return super.visitPropertyGet(node); |
| 652 } | 652 } |
| 653 | 653 |
| 654 TreeNode visitCatch(Catch node) { | 654 TreeNode visitCatch(Catch node) { |
| 655 VariableDeclaration exception = node.exception; | 655 VariableDeclaration exception = node.exception; |
| 656 VariableDeclaration stackTrace = node.stackTrace; | 656 VariableDeclaration stackTrace = node.stackTrace; |
| 657 if (stackTrace != null && capturedVariables.contains(stackTrace)) { | 657 if (stackTrace != null && capturedVariables.contains(stackTrace)) { |
| 658 Block block = node.body = ensureBlock(node.body); | 658 Block block = node.body = ensureBlock(node.body); |
| 659 block.parent = node; | 659 block.parent = node; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 newClassMembers.add(tearOffMethod); | 877 newClassMembers.add(tearOffMethod); |
| 878 | 878 |
| 879 resetContext(); | 879 resetContext(); |
| 880 }); | 880 }); |
| 881 } finally { | 881 } finally { |
| 882 currentMember = oldCurrentMember; | 882 currentMember = oldCurrentMember; |
| 883 currentMemberFunction = oldCurrentMemberFunction; | 883 currentMemberFunction = oldCurrentMemberFunction; |
| 884 } | 884 } |
| 885 } | 885 } |
| 886 } | 886 } |
| OLD | NEW |