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.dart_backend; | |
6 | |
7 import 'package:compiler/src/constant_system_dart.dart'; | |
8 import 'package:compiler/src/constants/constant_system.dart'; | |
9 import 'package:compiler/src/dart_backend/dart_backend.dart'; | |
10 import 'package:compiler/src/dart2jslib.dart'; | |
11 import 'package:compiler/src/dart_types.dart'; | |
12 import 'package:compiler/src/elements/elements.dart'; | |
13 | |
14 import 'driver.dart'; | |
15 import 'converted_world.dart'; | |
16 | |
17 void compileToDart(Driver driver, ConvertedWorld convertedWorld) { | |
18 DiagnosticListener listener = new Listener(); | |
19 DartOutputter outputter = new DartOutputter(listener, driver.outputProvider); | |
20 ElementAstCreationContext context = new _ElementAstCreationContext( | |
21 listener, convertedWorld.dartTypes); | |
22 outputter.assembleProgram( | |
23 libraries: convertedWorld.libraries, | |
24 instantiatedClasses: convertedWorld.instantiatedClasses, | |
25 resolvedElements: convertedWorld.resolvedElements, | |
26 mainFunction: convertedWorld.mainFunction, | |
27 computeElementAst: (Element element) { | |
28 return DartBackend.createElementAst( | |
29 context, | |
30 element, | |
31 convertedWorld.getIr(element)); | |
32 }, | |
33 shouldOutput: (Element element) => !element.isSynthesized, | |
34 isSafeToRemoveTypeDeclarations: (_) => false); | |
35 } | |
36 | |
37 class _ElementAstCreationContext implements ElementAstCreationContext { | |
38 final Listener listener; | |
39 | |
40 @override | |
41 final DartTypes dartTypes; | |
42 | |
43 _ElementAstCreationContext(this.listener, this.dartTypes); | |
44 | |
45 @override | |
46 ConstantSystem get constantSystem => DART_CONSTANT_SYSTEM; | |
47 | |
48 @override | |
49 InternalErrorFunction get internalError => listener.internalError; | |
50 | |
51 @override | |
52 void traceCompilation(String name) { | |
53 // Do nothing. | |
54 } | |
55 | |
56 @override | |
57 void traceGraph(String title, irObject) { | |
58 // Do nothing. | |
59 } | |
60 } | |
61 | |
62 class Listener implements DiagnosticListener { | |
63 | |
64 @override | |
65 void internalError(Spannable spannable, message) { | |
66 throw new UnimplementedError(message); | |
67 } | |
68 | |
69 @override | |
70 void log(message) { | |
71 // TODO: implement log | |
72 } | |
73 | |
74 @override | |
75 void reportError(Spannable node, | |
76 MessageKind errorCode, | |
77 [Map arguments = const {}]) { | |
78 // TODO: implement reportError | |
79 } | |
80 | |
81 @override | |
82 void reportHint(Spannable node, | |
83 MessageKind errorCode, | |
84 [Map arguments = const {}]) { | |
85 // TODO: implement reportHint | |
86 } | |
87 | |
88 @override | |
89 void reportInfo(Spannable node, | |
90 MessageKind errorCode, | |
91 [Map arguments = const {}]) { | |
92 // TODO: implement reportInfo | |
93 } | |
94 | |
95 @override | |
96 void reportWarning(Spannable node, | |
97 MessageKind errorCode, | |
98 [Map arguments = const {}]) { | |
99 // TODO: implement reportWarning | |
100 } | |
101 | |
102 @override | |
103 spanFromSpannable(Spannable node) { | |
104 // TODO: implement spanFromSpannable | |
105 } | |
106 | |
107 @override | |
108 withCurrentElement(element, f()) { | |
109 // TODO: implement withCurrentElement | |
110 } | |
111 } | |
OLD | NEW |