Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 library analyzer2dart.convertedWorld; | |
| 6 | |
| 7 import 'dart:collection'; | |
| 8 | |
| 9 import 'package:analyzer/analyzer.dart'; | |
| 10 import 'package:compiler/implementation/elements/elements.dart' as dart2js; | |
| 11 import 'package:analyzer/src/generated/element.dart' as analyzer; | |
| 12 import 'package:compiler/implementation/cps_ir/cps_ir_nodes.dart' as ir; | |
| 13 | |
| 14 import 'closed_world.dart'; | |
| 15 import 'element_converter.dart'; | |
| 16 import 'cps_generator.dart'; | |
| 17 | |
| 18 /// A [ClosedWorld] converted to the dart2js element model. | |
| 19 abstract class ConvertedWorld { | |
| 20 Iterable<dart2js.LibraryElement> get libraries; | |
| 21 Iterable<dart2js.AstElement> get resolvedElements; | |
| 22 Iterable<dart2js.ClassElement> get instantiatedClasses; | |
| 23 dart2js.FunctionElement get mainFunction; | |
| 24 ir.Node getIr(dart2js.Element element); | |
| 25 | |
| 26 } | |
| 27 | |
| 28 class _ConvertedWorldImpl implements ConvertedWorld { | |
| 29 final dart2js.FunctionElement mainFunction; | |
| 30 Map<dart2js.AstElement, ir.Node> executableElements = | |
| 31 new HashMap<dart2js.AstElement, ir.Node>(); | |
| 32 | |
| 33 _ConvertedWorldImpl(this.mainFunction); | |
| 34 | |
| 35 Iterable<dart2js.LibraryElement> get libraries => [mainFunction.library]; | |
| 36 | |
| 37 Iterable<dart2js.AstElement> get resolvedElements => executableElements.keys; | |
| 38 | |
| 39 Iterable<dart2js.ClassElement> get instantiatedClasses => []; | |
| 40 | |
| 41 ir.Node getIr(dart2js.Element element) => executableElements[element]; | |
| 42 } | |
| 43 | |
| 44 ConvertedWorld convertWorld(ClosedWorld closedWorld) { | |
| 45 ElementConverter converter = new ElementConverter(); | |
| 46 _ConvertedWorldImpl convertedWorld = new _ConvertedWorldImpl( | |
| 47 converter.convertElement(closedWorld.mainFunction)); | |
| 48 closedWorld.executableElements.forEach( | |
| 49 (analyzer.ExecutableElement analyzerElement, AstNode node) { | |
|
Brian Wilkerson
2014/09/08 13:47:08
Is this normal formatting? It looks strange to hav
Johnni Winther
2014/09/09 14:21:26
The body of a passed function expression is indent
| |
| 50 dart2js.AstElement dart2jsElement = | |
| 51 converter.convertElement(analyzerElement); | |
| 52 CpsGeneratingVisitor visitor = new CpsGeneratingVisitor(converter); | |
| 53 convertedWorld.executableElements[dart2jsElement] = node.accept(visitor); | |
| 54 }); | |
| 55 return convertedWorld; | |
| 56 } | |
| 57 | |
| OLD | NEW |