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

Side by Side Diff: pkg/compiler/lib/src/dart_backend/backend.dart

Issue 764023005: Generate typedef node from the element. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix unittest Created 6 years 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of dart_backend; 5 part of dart_backend;
6 6
7 // TODO(ahe): This class is simply wrong. This backend should use 7 // TODO(ahe): This class is simply wrong. This backend should use
8 // elements when it can, not AST nodes. Perhaps a [Map<Element, 8 // elements when it can, not AST nodes. Perhaps a [Map<Element,
9 // TreeElements>] is what is needed. 9 // TreeElements>] is what is needed.
10 class ElementAst { 10 class ElementAst {
11 final Node ast; 11 final Node ast;
12 final TreeElements treeElements; 12 final TreeElements treeElements;
13 13
14 ElementAst(AstElement element) 14 ElementAst(this.ast, this.treeElements);
15 : this.internal(element.resolvedAst.node, element.resolvedAst.elements);
16
17 ElementAst.internal(this.ast, this.treeElements);
18 } 15 }
19 16
20 class DartBackend extends Backend { 17 class DartBackend extends Backend {
21 final List<CompilerTask> tasks; 18 final List<CompilerTask> tasks;
22 final bool stripAsserts; 19 final bool stripAsserts;
23 20
24 // TODO(zarah) Maybe change this to a command-line option. 21 // TODO(zarah) Maybe change this to a command-line option.
25 // Right now, it is set by the tests. 22 // Right now, it is set by the tests.
26 bool useMirrorHelperLibrary = false; 23 bool useMirrorHelperLibrary = false;
27 24
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 traceGraph('Loop rewriter', treeDefinition); 172 traceGraph('Loop rewriter', treeDefinition);
176 new LogicalRewriter().rewrite(treeDefinition); 173 new LogicalRewriter().rewrite(treeDefinition);
177 traceGraph('Logical rewriter', treeDefinition); 174 traceGraph('Logical rewriter', treeDefinition);
178 new backend_ast_emitter.UnshadowParameters().unshadow(treeDefinition); 175 new backend_ast_emitter.UnshadowParameters().unshadow(treeDefinition);
179 traceGraph('Unshadow parameters', treeDefinition); 176 traceGraph('Unshadow parameters', treeDefinition);
180 177
181 TreeElementMapping treeElements = new TreeElementMapping(element); 178 TreeElementMapping treeElements = new TreeElementMapping(element);
182 backend_ast.ExecutableDefinition backendAst = 179 backend_ast.ExecutableDefinition backendAst =
183 backend_ast_emitter.emit(treeDefinition); 180 backend_ast_emitter.emit(treeDefinition);
184 Node frontend_ast = backend2frontend.emit(treeElements, backendAst); 181 Node frontend_ast = backend2frontend.emit(treeElements, backendAst);
185 return new ElementAst.internal(frontend_ast, treeElements); 182 return new ElementAst(frontend_ast, treeElements);
186 183
187 } 184 }
188 185
189 /** 186 /**
190 * Tells whether we should output given element. Corelib classes like 187 * Tells whether we should output given element. Corelib classes like
191 * Object should not be in the resulting code. 188 * Object should not be in the resulting code.
192 */ 189 */
193 @override 190 @override
194 bool shouldOutput(Element element) { 191 bool shouldOutput(Element element) {
195 return (!element.library.isPlatformLibrary && 192 return (!element.library.isPlatformLibrary &&
196 !element.isSynthesized && 193 !element.isSynthesized &&
197 element is! AbstractFieldElement) 194 element is! AbstractFieldElement)
198 || mirrorRenamer.isMirrorHelperLibrary(element.library); 195 || mirrorRenamer.isMirrorHelperLibrary(element.library);
199 } 196 }
200 197
201 void assembleProgram() { 198 void assembleProgram() {
202 199
203 ElementAst computeElementAst(AstElement element) { 200 ElementAst computeElementAst(AstElement element) {
204 if (!compiler.irBuilder.hasIr(element)) { 201 if (!compiler.irBuilder.hasIr(element)) {
205 return new ElementAst(element); 202 return new ElementAst(element.resolvedAst.node,
203 element.resolvedAst.elements);
206 } else { 204 } else {
207 cps_ir.ExecutableDefinition definition = 205 cps_ir.ExecutableDefinition definition =
208 compiler.irBuilder.getIr(element); 206 compiler.irBuilder.getIr(element);
209 return createElementAst(compiler, 207 return createElementAst(compiler,
210 compiler.tracer, constantSystem, element, definition); 208 compiler.tracer, constantSystem, element, definition);
211 } 209 }
212 } 210 }
213 211
214 // TODO(johnniwinther): Remove the need for this method. 212 // TODO(johnniwinther): Remove the need for this method.
215 void postProcessElementAst( 213 void postProcessElementAst(
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 } 516 }
519 517
520 ConstantExpression compileMetadata(MetadataAnnotation metadata, 518 ConstantExpression compileMetadata(MetadataAnnotation metadata,
521 Node node, 519 Node node,
522 TreeElements elements) { 520 TreeElements elements) {
523 return measure(() { 521 return measure(() {
524 return constantCompiler.compileMetadata(metadata, node, elements); 522 return constantCompiler.compileMetadata(metadata, node, elements);
525 }); 523 });
526 } 524 }
527 } 525 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698