| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart2js.ir_builder; | 5 part of dart2js.ir_builder; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * This task iterates through all resolved elements and builds [ir.Node]s. The | 8 * This task iterates through all resolved elements and builds [ir.Node]s. The |
| 9 * nodes are stored in the [nodes] map and accessible through [hasIr] and | 9 * nodes are stored in the [nodes] map and accessible through [hasIr] and |
| 10 * [getIr]. | 10 * [getIr]. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 ir.FunctionDefinition getIr(Element element) => nodes[element.implementation]; | 34 ir.FunctionDefinition getIr(Element element) => nodes[element.implementation]; |
| 35 | 35 |
| 36 ir.FunctionDefinition buildNode(AstElement element) { | 36 ir.FunctionDefinition buildNode(AstElement element) { |
| 37 if (!canBuild(element)) return null; | 37 if (!canBuild(element)) return null; |
| 38 TreeElements elementsMapping = element.resolvedAst.elements; | 38 TreeElements elementsMapping = element.resolvedAst.elements; |
| 39 element = element.implementation; | 39 element = element.implementation; |
| 40 return compiler.withCurrentElement(element, () { | 40 return compiler.withCurrentElement(element, () { |
| 41 SourceFile sourceFile = elementSourceFile(element); | 41 SourceFile sourceFile = elementSourceFile(element); |
| 42 IrBuilderVisitor builder = | 42 IrBuilderVisitor builder = |
| 43 new IrBuilderVisitor(elementsMapping, compiler, sourceFile); | 43 new IrBuilderVisitor(elementsMapping, compiler, sourceFile); |
| 44 ir.FunctionDefinition function; | 44 return builder.buildFunction(element); |
| 45 function = builder.buildFunction(element); | |
| 46 | |
| 47 return function; | |
| 48 }); | 45 }); |
| 49 } | 46 } |
| 50 | 47 |
| 51 void buildNodes() { | 48 void buildNodes() { |
| 52 measure(() { | 49 measure(() { |
| 53 Set<Element> resolved = compiler.enqueuer.resolution.resolvedElements; | 50 Set<Element> resolved = compiler.enqueuer.resolution.resolvedElements; |
| 54 resolved.forEach((AstElement element) { | 51 resolved.forEach((AstElement element) { |
| 55 ir.FunctionDefinition functionDefinition = buildNode(element); | 52 ir.FunctionDefinition functionDefinition = buildNode(element); |
| 56 if (functionDefinition != null) { | 53 if (functionDefinition != null) { |
| 57 nodes[element] = functionDefinition; | 54 nodes[element] = functionDefinition; |
| (...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 node.visitChildren(this); | 876 node.visitChildren(this); |
| 880 } | 877 } |
| 881 | 878 |
| 882 visitFunctionExpression(ast.FunctionExpression node) { | 879 visitFunctionExpression(ast.FunctionExpression node) { |
| 883 FunctionElement oldFunction = currentFunction; | 880 FunctionElement oldFunction = currentFunction; |
| 884 currentFunction = elements[node]; | 881 currentFunction = elements[node]; |
| 885 visit(node.body); | 882 visit(node.body); |
| 886 currentFunction = oldFunction; | 883 currentFunction = oldFunction; |
| 887 } | 884 } |
| 888 } | 885 } |
| OLD | NEW |