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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 final Map<JumpTarget, ir.LabeledStatement> breakTargets = | 192 final Map<JumpTarget, ir.LabeledStatement> breakTargets = |
193 <JumpTarget, ir.LabeledStatement>{}; | 193 <JumpTarget, ir.LabeledStatement>{}; |
194 | 194 |
195 final Map<LocalElement, ir.VariableDeclaration> locals = | 195 final Map<LocalElement, ir.VariableDeclaration> locals = |
196 <LocalElement, ir.VariableDeclaration>{}; | 196 <LocalElement, ir.VariableDeclaration>{}; |
197 | 197 |
198 final Map<CascadeReceiver, ir.VariableGet> cascadeReceivers = | 198 final Map<CascadeReceiver, ir.VariableGet> cascadeReceivers = |
199 <CascadeReceiver, ir.VariableGet>{}; | 199 <CascadeReceiver, ir.VariableGet>{}; |
200 | 200 |
201 final Map<ir.Node, Element> nodeToElement = <ir.Node, Element>{}; | |
202 final Map<ir.Node, Node> nodeToAst = <ir.Node, Node>{}; | |
203 | |
204 ir.Node associateElement(ir.Node node, Element element) { | 201 ir.Node associateElement(ir.Node node, Element element) { |
205 nodeToElement[node] = element; | 202 kernel.nodeToElement[node] = element; |
206 return node; | 203 return node; |
207 } | 204 } |
208 | 205 |
209 ir.Node associateNode(ir.Node node, Node ast) { | 206 ir.Node associateNode(ir.Node node, Node ast) { |
210 nodeToAst[node] = ast; | 207 kernel.nodeToAst[node] = ast; |
211 return node; | 208 return node; |
212 } | 209 } |
213 | 210 |
214 bool isVoidContext = false; | 211 bool isVoidContext = false; |
215 | 212 |
216 KernelVisitor(this.currentElement, this.elements, this.kernel); | 213 KernelVisitor(this.currentElement, this.elements, this.kernel); |
217 | 214 |
218 KernelVisitor get sendVisitor => this; | 215 KernelVisitor get sendVisitor => this; |
219 | 216 |
220 KernelVisitor get declVisitor => this; | 217 KernelVisitor get declVisitor => this; |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 | 895 |
899 @override | 896 @override |
900 ir.Expression visitLiteralString(LiteralString node) { | 897 ir.Expression visitLiteralString(LiteralString node) { |
901 if (node.dartString == null) return new ir.InvalidExpression(); | 898 if (node.dartString == null) return new ir.InvalidExpression(); |
902 return new ir.StringLiteral(node.dartString.slowToString()); | 899 return new ir.StringLiteral(node.dartString.slowToString()); |
903 } | 900 } |
904 | 901 |
905 @override | 902 @override |
906 ir.SymbolLiteral visitLiteralSymbol(LiteralSymbol node) { | 903 ir.SymbolLiteral visitLiteralSymbol(LiteralSymbol node) { |
907 var result = new ir.SymbolLiteral(node.slowNameString); | 904 var result = new ir.SymbolLiteral(node.slowNameString); |
908 nodeToAst[result] = node; | 905 return associateNode(result, node); |
909 return result; | |
910 } | 906 } |
911 | 907 |
912 @override | 908 @override |
913 visitMetadata(Metadata node) { | 909 visitMetadata(Metadata node) { |
914 // Shouldn't be called. Metadata should already have been analyzed and | 910 // Shouldn't be called. Metadata should already have been analyzed and |
915 // converted to a constant expression in the resolver. | 911 // converted to a constant expression in the resolver. |
916 return internalError(node, "Metadata not handled as constant."); | 912 return internalError(node, "Metadata not handled as constant."); |
917 } | 913 } |
918 | 914 |
919 @override | 915 @override |
(...skipping 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2714 : this(null, true, node, initializers); | 2710 : this(null, true, node, initializers); |
2715 | 2711 |
2716 accept(ir.Visitor v) => throw "unsupported"; | 2712 accept(ir.Visitor v) => throw "unsupported"; |
2717 | 2713 |
2718 visitChildren(ir.Visitor v) => throw "unsupported"; | 2714 visitChildren(ir.Visitor v) => throw "unsupported"; |
2719 | 2715 |
2720 String toString() { | 2716 String toString() { |
2721 return "IrFunction($kind, $isConstructor, $node, $initializers)"; | 2717 return "IrFunction($kind, $isConstructor, $node, $initializers)"; |
2722 } | 2718 } |
2723 } | 2719 } |
OLD | NEW |