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

Side by Side Diff: pkg/analyzer2dart/lib/src/converted_world.dart

Issue 609783002: Support static field access in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/implementation/elements/elements.dart' as dart2js; 10 import 'package:compiler/implementation/elements/elements.dart' as dart2js;
(...skipping 14 matching lines...) Expand all
25 25
26 } 26 }
27 27
28 class _ConvertedWorldImpl implements ConvertedWorld { 28 class _ConvertedWorldImpl implements ConvertedWorld {
29 final dart2js.FunctionElement mainFunction; 29 final dart2js.FunctionElement mainFunction;
30 Map<dart2js.AstElement, ir.Node> executableElements = 30 Map<dart2js.AstElement, ir.Node> executableElements =
31 new HashMap<dart2js.AstElement, ir.Node>(); 31 new HashMap<dart2js.AstElement, ir.Node>();
32 32
33 _ConvertedWorldImpl(this.mainFunction); 33 _ConvertedWorldImpl(this.mainFunction);
34 34
35 // TODO(johnniwinther): Add all used libraries and all SDK libraries to the
36 // set of libraries in the converted world.
35 Iterable<dart2js.LibraryElement> get libraries => [mainFunction.library]; 37 Iterable<dart2js.LibraryElement> get libraries => [mainFunction.library];
36 38
37 Iterable<dart2js.AstElement> get resolvedElements => executableElements.keys; 39 Iterable<dart2js.AstElement> get resolvedElements => executableElements.keys;
38 40
39 Iterable<dart2js.ClassElement> get instantiatedClasses => []; 41 Iterable<dart2js.ClassElement> get instantiatedClasses => [];
40 42
41 ir.Node getIr(dart2js.Element element) => executableElements[element]; 43 ir.Node getIr(dart2js.Element element) => executableElements[element];
42 } 44 }
43 45
44 ConvertedWorld convertWorld(ClosedWorld closedWorld) { 46 ConvertedWorld convertWorld(ClosedWorld closedWorld) {
45 ElementConverter converter = new ElementConverter(); 47 ElementConverter converter = new ElementConverter();
46 _ConvertedWorldImpl convertedWorld = new _ConvertedWorldImpl( 48 _ConvertedWorldImpl convertedWorld = new _ConvertedWorldImpl(
47 converter.convertElement(closedWorld.mainFunction)); 49 converter.convertElement(closedWorld.mainFunction));
48 closedWorld.executableElements.forEach( 50
49 (analyzer.ExecutableElement analyzerElement, AstNode node) { 51 void convert(analyzer.Element analyzerElement, AstNode node) {
52 // Skip conversion of SDK sources since we don't generate code for it
53 // anyway.
54 if (analyzerElement.source.isInSystemLibrary) return;
55
50 dart2js.AstElement dart2jsElement = 56 dart2js.AstElement dart2jsElement =
51 converter.convertElement(analyzerElement); 57 converter.convertElement(analyzerElement);
52 CpsGeneratingVisitor visitor = new CpsGeneratingVisitor(converter); 58 CpsGeneratingVisitor visitor =
53 convertedWorld.executableElements[dart2jsElement] = node.accept(visitor); 59 new CpsGeneratingVisitor(converter, analyzerElement);
54 }); 60 ir.Node cpsNode = node.accept(visitor);
61 if (cpsNode != null) {
62 convertedWorld.executableElements[dart2jsElement] = cpsNode;
63 } else {
64 visitor.giveUp(node,
65 'No CPS node generated for $analyzerElement (${node.runtimeType}).');
66 }
67 }
68
69 closedWorld.executableElements.forEach(convert);
70 closedWorld.variables.forEach(convert);
71 closedWorld.fields.forEach(convert);
72
55 return convertedWorld; 73 return convertedWorld;
56 } 74 }
57 75
OLDNEW
« no previous file with comments | « pkg/analyzer2dart/lib/src/closed_world.dart ('k') | pkg/analyzer2dart/lib/src/cps_generator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698