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 import 'package:compiler/src/elements/elements.dart'; | 5 import 'package:compiler/src/elements/elements.dart'; |
6 import 'package:compiler/src/resolution/access_semantics.dart'; | 6 import 'package:compiler/src/resolution/access_semantics.dart'; |
7 import 'package:compiler/src/resolution/send_structure.dart'; | 7 import 'package:compiler/src/resolution/send_structure.dart'; |
8 import 'package:compiler/src/resolution/tree_elements.dart'; | 8 import 'package:compiler/src/resolution/tree_elements.dart'; |
9 import 'package:compiler/src/tree/nodes.dart' as ast; | 9 import 'package:compiler/src/tree/nodes.dart' as ast; |
10 import 'package:kernel/ast.dart' as ir; | 10 import 'package:kernel/ast.dart' as ir; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 Id computeNodeId(ir.TreeNode node) { | 206 Id computeNodeId(ir.TreeNode node) { |
207 if (node is ir.MethodInvocation) { | 207 if (node is ir.MethodInvocation) { |
208 assert(node.fileOffset != ir.TreeNode.noOffset); | 208 assert(node.fileOffset != ir.TreeNode.noOffset); |
209 return new NodeId(node.fileOffset); | 209 return new NodeId(node.fileOffset); |
210 } else if (node is ir.PropertyGet) { | 210 } else if (node is ir.PropertyGet) { |
211 assert(node.fileOffset != ir.TreeNode.noOffset); | 211 assert(node.fileOffset != ir.TreeNode.noOffset); |
212 return new NodeId(node.fileOffset); | 212 return new NodeId(node.fileOffset); |
213 } else if (node is ir.VariableDeclaration) { | 213 } else if (node is ir.VariableDeclaration) { |
214 assert(node.fileOffset != ir.TreeNode.noOffset); | 214 assert(node.fileOffset != ir.TreeNode.noOffset); |
215 return new NodeId(node.fileOffset); | 215 return new NodeId(node.fileOffset); |
216 // TODO(johnniwinther): Enable when function expressions have offsets. | 216 } else if (node is ir.FunctionExpression) { |
217 /*} else if (node is ir.FunctionExpression) { | |
218 assert(node.fileOffset != ir.TreeNode.noOffset); | 217 assert(node.fileOffset != ir.TreeNode.noOffset); |
219 return new NodeId(node.fileOffset);*/ | 218 return new NodeId(node.fileOffset); |
220 } else if (node is ir.FunctionDeclaration) { | 219 } else if (node is ir.FunctionDeclaration) { |
221 assert(node.fileOffset != ir.TreeNode.noOffset); | 220 assert(node.fileOffset != ir.TreeNode.noOffset); |
222 return new NodeId(node.fileOffset); | 221 return new NodeId(node.fileOffset); |
223 } | 222 } |
224 return null; | 223 return null; |
225 } | 224 } |
226 } | 225 } |
227 | 226 |
228 /// Visitor that finds the IR node corresponding to an [Id]. | 227 /// Visitor that finds the IR node corresponding to an [Id]. |
229 class IrIdFinder extends ir.Visitor with IrEnumeratorMixin { | 228 class IrIdFinder extends ir.Visitor with IrEnumeratorMixin { |
(...skipping 24 matching lines...) Expand all Loading... |
254 if (found == null) { | 253 if (found == null) { |
255 Id id = computeElementId(node); | 254 Id id = computeElementId(node); |
256 if (id == soughtId) { | 255 if (id == soughtId) { |
257 found = node; | 256 found = node; |
258 return; | 257 return; |
259 } | 258 } |
260 defaultTreeNode(node); | 259 defaultTreeNode(node); |
261 } | 260 } |
262 } | 261 } |
263 } | 262 } |
OLD | NEW |