| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 library analyzer2dart.convertedWorld; | 5 library analyzer2dart.convertedWorld; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
| 10 import 'package:compiler/src/elements/elements.dart' as dart2js; | 10 import 'package:compiler/src/elements/elements.dart' as dart2js; |
| 11 import 'package:analyzer/src/generated/element.dart' as analyzer; | 11 import 'package:analyzer/src/generated/element.dart' as analyzer; |
| 12 import 'package:compiler/src/cps_ir/cps_ir_nodes.dart' as ir; | 12 import 'package:compiler/src/cps_ir/cps_ir_nodes.dart' as ir; |
| 13 | 13 |
| 14 import 'closed_world.dart'; | 14 import 'closed_world.dart'; |
| 15 import 'element_converter.dart'; | 15 import 'element_converter.dart'; |
| 16 import 'cps_generator.dart'; | 16 import 'cps_generator.dart'; |
| 17 import 'util.dart'; |
| 17 | 18 |
| 18 /// A [ClosedWorld] converted to the dart2js element model. | 19 /// A [ClosedWorld] converted to the dart2js element model. |
| 19 abstract class ConvertedWorld { | 20 abstract class ConvertedWorld { |
| 20 Iterable<dart2js.LibraryElement> get libraries; | 21 Iterable<dart2js.LibraryElement> get libraries; |
| 21 Iterable<dart2js.AstElement> get resolvedElements; | 22 Iterable<dart2js.AstElement> get resolvedElements; |
| 22 Iterable<dart2js.ClassElement> get instantiatedClasses; | 23 Iterable<dart2js.ClassElement> get instantiatedClasses; |
| 23 dart2js.FunctionElement get mainFunction; | 24 dart2js.FunctionElement get mainFunction; |
| 24 ir.Node getIr(dart2js.Element element); | 25 ir.Node getIr(dart2js.Element element); |
| 25 | 26 |
| 26 } | 27 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 _ConvertedWorldImpl convertedWorld = new _ConvertedWorldImpl( | 49 _ConvertedWorldImpl convertedWorld = new _ConvertedWorldImpl( |
| 49 converter.convertElement(closedWorld.mainFunction)); | 50 converter.convertElement(closedWorld.mainFunction)); |
| 50 | 51 |
| 51 void convert(analyzer.Element analyzerElement, AstNode node) { | 52 void convert(analyzer.Element analyzerElement, AstNode node) { |
| 52 // Skip conversion of SDK sources since we don't generate code for it | 53 // Skip conversion of SDK sources since we don't generate code for it |
| 53 // anyway. | 54 // anyway. |
| 54 if (analyzerElement.source.isInSystemLibrary) return; | 55 if (analyzerElement.source.isInSystemLibrary) return; |
| 55 | 56 |
| 56 dart2js.AstElement dart2jsElement = | 57 dart2js.AstElement dart2jsElement = |
| 57 converter.convertElement(analyzerElement); | 58 converter.convertElement(analyzerElement); |
| 58 CpsGeneratingVisitor visitor = | 59 CpsElementVisitor visitor = new CpsElementVisitor(converter, node); |
| 59 new CpsGeneratingVisitor(converter, analyzerElement); | 60 ir.Node cpsNode = analyzerElement.accept(visitor); |
| 60 ir.Node cpsNode = node.accept(visitor); | |
| 61 if (cpsNode != null) { | 61 if (cpsNode != null) { |
| 62 convertedWorld.executableElements[dart2jsElement] = cpsNode; | 62 convertedWorld.executableElements[dart2jsElement] = cpsNode; |
| 63 } else { | 63 } else { |
| 64 visitor.giveUp(node, | 64 String message = |
| 65 'No CPS node generated for $analyzerElement (${node.runtimeType}).'); | 65 'No CPS node generated for $analyzerElement (${node.runtimeType}).'; |
| 66 reportSourceMessage(analyzerElement.source, node, message); |
| 67 throw new UnimplementedError(message); |
| 66 } | 68 } |
| 67 } | 69 } |
| 68 | 70 |
| 69 closedWorld.executableElements.forEach(convert); | 71 closedWorld.executableElements.forEach(convert); |
| 70 closedWorld.variables.forEach(convert); | 72 closedWorld.variables.forEach(convert); |
| 71 closedWorld.fields.forEach(convert); | 73 closedWorld.fields.forEach(convert); |
| 72 | 74 |
| 73 return convertedWorld; | 75 return convertedWorld; |
| 74 } | 76 } |
| 75 | |
| OLD | NEW |