Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: pkg/analyzer2dart/lib/src/converted_world.dart

Issue 548253003: First end-to-end capability in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer2dart/lib/src/converted_world.dart
diff --git a/pkg/analyzer2dart/lib/src/converted_world.dart b/pkg/analyzer2dart/lib/src/converted_world.dart
new file mode 100644
index 0000000000000000000000000000000000000000..82a7ccb8c0757d90044c49930c7ff6f27ec011d0
--- /dev/null
+++ b/pkg/analyzer2dart/lib/src/converted_world.dart
@@ -0,0 +1,57 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library analyzer2dart.convertedWorld;
+
+import 'dart:collection';
+
+import 'package:analyzer/analyzer.dart';
+import 'package:compiler/implementation/elements/elements.dart' as dart2js;
+import 'package:analyzer/src/generated/element.dart' as analyzer;
+import 'package:compiler/implementation/cps_ir/cps_ir_nodes.dart' as ir;
+
+import 'closed_world.dart';
+import 'element_converter.dart';
+import 'cps_generator.dart';
+
+/// A [ClosedWorld] converted to the dart2js element model.
+abstract class ConvertedWorld {
+ Iterable<dart2js.LibraryElement> get libraries;
+ Iterable<dart2js.AstElement> get resolvedElements;
+ Iterable<dart2js.ClassElement> get instantiatedClasses;
+ dart2js.FunctionElement get mainFunction;
+ ir.Node getIr(dart2js.Element element);
+
+}
+
+class _ConvertedWorldImpl implements ConvertedWorld {
+ final dart2js.FunctionElement mainFunction;
+ Map<dart2js.AstElement, ir.Node> executableElements =
+ new HashMap<dart2js.AstElement, ir.Node>();
+
+ _ConvertedWorldImpl(this.mainFunction);
+
+ Iterable<dart2js.LibraryElement> get libraries => [mainFunction.library];
+
+ Iterable<dart2js.AstElement> get resolvedElements => executableElements.keys;
+
+ Iterable<dart2js.ClassElement> get instantiatedClasses => [];
+
+ ir.Node getIr(dart2js.Element element) => executableElements[element];
+}
+
+ConvertedWorld convertWorld(ClosedWorld closedWorld) {
+ ElementConverter converter = new ElementConverter();
+ _ConvertedWorldImpl convertedWorld = new _ConvertedWorldImpl(
+ converter.convertElement(closedWorld.mainFunction));
+ closedWorld.executableElements.forEach(
+ (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
+ dart2js.AstElement dart2jsElement =
+ converter.convertElement(analyzerElement);
+ CpsGeneratingVisitor visitor = new CpsGeneratingVisitor(converter);
+ convertedWorld.executableElements[dart2jsElement] = node.accept(visitor);
+ });
+ return convertedWorld;
+}
+

Powered by Google App Engine
This is Rietveld 408576698