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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
6 import 'package:kernel/frontend/accessors.dart' | 6 import 'package:kernel/frontend/accessors.dart' |
7 show | 7 show |
8 Accessor, | 8 Accessor, |
9 IndexAccessor, | 9 IndexAccessor, |
10 NullAwarePropertyAccessor, | 10 NullAwarePropertyAccessor, |
(...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1682 // TODO(ahe): Use [constant]? | 1682 // TODO(ahe): Use [constant]? |
1683 return buildLocalVariableDeclaration(variable, variable.initializer) | 1683 return buildLocalVariableDeclaration(variable, variable.initializer) |
1684 ..isConst = true; | 1684 ..isConst = true; |
1685 } | 1685 } |
1686 | 1686 |
1687 @override | 1687 @override |
1688 ir.FunctionDeclaration visitLocalFunctionDeclaration(FunctionExpression node, | 1688 ir.FunctionDeclaration visitLocalFunctionDeclaration(FunctionExpression node, |
1689 LocalFunctionElement localFunction, NodeList parameters, Node body, _) { | 1689 LocalFunctionElement localFunction, NodeList parameters, Node body, _) { |
1690 return withCurrentElement(localFunction, () { | 1690 return withCurrentElement(localFunction, () { |
1691 ir.VariableDeclaration local = getLocal(localFunction)..isFinal = true; | 1691 ir.VariableDeclaration local = getLocal(localFunction)..isFinal = true; |
1692 return new ir.FunctionDeclaration( | 1692 ir.FunctionDeclaration function = new ir.FunctionDeclaration( |
1693 local, buildFunctionNode(localFunction, body)); | 1693 local, buildFunctionNode(localFunction, body)); |
| 1694 // Closures can escape their context and we must therefore store them |
| 1695 // globally to include them in the world computation. |
| 1696 kernel.localFunctions[localFunction] = function; |
| 1697 return function; |
1694 }); | 1698 }); |
1695 } | 1699 } |
1696 | 1700 |
1697 @override | 1701 @override |
1698 ir.VariableDeclaration visitLocalVariableDeclaration(VariableDefinitions node, | 1702 ir.VariableDeclaration visitLocalVariableDeclaration(VariableDefinitions node, |
1699 Node definition, LocalVariableElement variable, Node initializer, _) { | 1703 Node definition, LocalVariableElement variable, Node initializer, _) { |
1700 return buildLocalVariableDeclaration(variable, initializer); | 1704 return buildLocalVariableDeclaration(variable, initializer); |
1701 } | 1705 } |
1702 | 1706 |
1703 ir.VariableGet buildLocalGet(LocalElement local) { | 1707 ir.VariableGet buildLocalGet(LocalElement local) { |
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2752 : this(null, true, node, initializers); | 2756 : this(null, true, node, initializers); |
2753 | 2757 |
2754 accept(ir.Visitor v) => throw "unsupported"; | 2758 accept(ir.Visitor v) => throw "unsupported"; |
2755 | 2759 |
2756 visitChildren(ir.Visitor v) => throw "unsupported"; | 2760 visitChildren(ir.Visitor v) => throw "unsupported"; |
2757 | 2761 |
2758 String toString() { | 2762 String toString() { |
2759 return "IrFunction($kind, $isConstructor, $node, $initializers)"; | 2763 return "IrFunction($kind, $isConstructor, $node, $initializers)"; |
2760 } | 2764 } |
2761 } | 2765 } |
OLD | NEW |