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

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

Issue 1421463005: Move codegen registration to transformImpact method. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 1 month 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
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/dart_backend/dart_backend.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 {
(...skipping 24 matching lines...) Expand all
35 Map<ClassNode, List<Node>> get memberNodes => outputter.output.memberNodes; 35 Map<ClassNode, List<Node>> get memberNodes => outputter.output.memberNodes;
36 36
37 ConstantSystem get constantSystem { 37 ConstantSystem get constantSystem {
38 return constantCompilerTask.constantCompiler.constantSystem; 38 return constantCompilerTask.constantCompiler.constantSystem;
39 } 39 }
40 40
41 BackendConstantEnvironment get constants => constantCompilerTask; 41 BackendConstantEnvironment get constants => constantCompilerTask;
42 42
43 DartConstantTask constantCompilerTask; 43 DartConstantTask constantCompilerTask;
44 44
45 DartResolutionCallbacks resolutionCallbacks; 45 DartImpactTransformer impactTransformer;
46 46
47 final Set<ClassElement> usedTypeLiterals = new Set<ClassElement>(); 47 final Set<ClassElement> usedTypeLiterals = new Set<ClassElement>();
48 48
49 /// The set of visible platform classes that are implemented by instantiated 49 /// The set of visible platform classes that are implemented by instantiated
50 /// user classes. 50 /// user classes.
51 final Set<ClassElement> _userImplementedPlatformClasses = 51 final Set<ClassElement> _userImplementedPlatformClasses =
52 new Set<ClassElement>(); 52 new Set<ClassElement>();
53 53
54 bool enableCodegenWithErrorsIfSupported(Spannable node) { 54 bool enableCodegenWithErrorsIfSupported(Spannable node) {
55 reporter.reportHintMessage( 55 reporter.reportHintMessage(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 DartBackend(Compiler compiler, List<String> strips, {bool multiFile}) 106 DartBackend(Compiler compiler, List<String> strips, {bool multiFile})
107 : tasks = <CompilerTask>[], 107 : tasks = <CompilerTask>[],
108 stripAsserts = strips.indexOf('asserts') != -1, 108 stripAsserts = strips.indexOf('asserts') != -1,
109 constantCompilerTask = new DartConstantTask(compiler), 109 constantCompilerTask = new DartConstantTask(compiler),
110 outputter = new DartOutputter( 110 outputter = new DartOutputter(
111 compiler.reporter, compiler.outputProvider, 111 compiler.reporter, compiler.outputProvider,
112 forceStripTypes: strips.indexOf('types') != -1, 112 forceStripTypes: strips.indexOf('types') != -1,
113 multiFile: multiFile, 113 multiFile: multiFile,
114 enableMinification: compiler.enableMinification), 114 enableMinification: compiler.enableMinification),
115 super(compiler) { 115 super(compiler) {
116 resolutionCallbacks = new DartResolutionCallbacks(this); 116 impactTransformer = new DartImpactTransformer(this);
117 } 117 }
118 118
119 119
120 DiagnosticReporter get reporter => compiler.reporter; 120 DiagnosticReporter get reporter => compiler.reporter;
121 121
122 Resolution get resolution => compiler.resolution; 122 Resolution get resolution => compiler.resolution;
123 123
124 bool classNeedsRti(ClassElement cls) => false; 124 bool classNeedsRti(ClassElement cls) => false;
125 bool methodNeedsRti(FunctionElement function) => false; 125 bool methodNeedsRti(FunctionElement function) => false;
126 126
(...skipping 12 matching lines...) Expand all
139 // we don't trust the resolution to always get these included. 139 // we don't trust the resolution to always get these included.
140 world.registerInvocation(new UniverseSelector(Selectors.toString_, null)); 140 world.registerInvocation(new UniverseSelector(Selectors.toString_, null));
141 world.registerInvokedGetter( 141 world.registerInvokedGetter(
142 new UniverseSelector(Selectors.hashCode_, null)); 142 new UniverseSelector(Selectors.hashCode_, null));
143 world.registerInvocation( 143 world.registerInvocation(
144 new UniverseSelector(new Selector.binaryOperator('=='), null)); 144 new UniverseSelector(new Selector.binaryOperator('=='), null));
145 world.registerInvocation( 145 world.registerInvocation(
146 new UniverseSelector(Selectors.compareTo, null)); 146 new UniverseSelector(Selectors.compareTo, null));
147 } 147 }
148 148
149 WorldImpact codegen(CodegenWorkItem work) => const WorldImpact(); 149 WorldImpact codegen(CodegenWorkItem work) {
150 return const WorldImpact();
151 }
150 152
151 /** 153 /**
152 * Tells whether we should output given element. Corelib classes like 154 * Tells whether we should output given element. Corelib classes like
153 * Object should not be in the resulting code. 155 * Object should not be in the resulting code.
154 */ 156 */
155 @override 157 @override
156 bool shouldOutput(Element element) { 158 bool shouldOutput(Element element) {
157 return (!element.library.isPlatformLibrary && 159 return (!element.library.isPlatformLibrary &&
158 !element.isSynthesized && 160 !element.isSynthesized &&
159 element is! AbstractFieldElement) 161 element is! AbstractFieldElement)
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 350
349 @override 351 @override
350 bool enableDeferredLoadingIfSupported(Spannable node, Registry registry) { 352 bool enableDeferredLoadingIfSupported(Spannable node, Registry registry) {
351 // TODO(sigurdm): Implement deferred loading for dart2dart. 353 // TODO(sigurdm): Implement deferred loading for dart2dart.
352 reporter.reportWarningMessage( 354 reporter.reportWarningMessage(
353 node, MessageKind.DEFERRED_LIBRARY_DART_2_DART); 355 node, MessageKind.DEFERRED_LIBRARY_DART_2_DART);
354 return false; 356 return false;
355 } 357 }
356 } 358 }
357 359
358 class DartResolutionCallbacks extends ResolutionCallbacks { 360 class DartImpactTransformer extends ImpactTransformer {
359 final DartBackend backend; 361 final DartBackend backend;
360 362
361 DartResolutionCallbacks(this.backend); 363 DartImpactTransformer(this.backend);
362 364
363 @override 365 @override
364 WorldImpact transformImpact(ResolutionImpact worldImpact) { 366 WorldImpact transformResolutionImpact(ResolutionImpact worldImpact) {
365 TransformedWorldImpact transformed = 367 TransformedWorldImpact transformed =
366 new TransformedWorldImpact(worldImpact); 368 new TransformedWorldImpact(worldImpact);
367 for (DartType typeLiteral in worldImpact.typeLiterals) { 369 for (DartType typeLiteral in worldImpact.typeLiterals) {
368 if (typeLiteral.isInterfaceType) { 370 if (typeLiteral.isInterfaceType) {
369 backend.usedTypeLiterals.add(typeLiteral.element); 371 backend.usedTypeLiterals.add(typeLiteral.element);
370 } 372 }
371 } 373 }
372 for (InterfaceType instantiatedType in worldImpact.instantiatedTypes) { 374 for (InterfaceType instantiatedType in worldImpact.instantiatedTypes) {
373 // TODO(johnniwinther): Remove this when dependency tracking is done on 375 // TODO(johnniwinther): Remove this when dependency tracking is done on
374 // the world impact itself. 376 // the world impact itself.
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 } 558 }
557 559
558 // TODO(johnniwinther): Remove this when values are computed from the 560 // TODO(johnniwinther): Remove this when values are computed from the
559 // expressions. 561 // expressions.
560 @override 562 @override
561 void copyConstantValues(DartConstantTask task) { 563 void copyConstantValues(DartConstantTask task) {
562 constantCompiler.constantValueMap.addAll( 564 constantCompiler.constantValueMap.addAll(
563 task.constantCompiler.constantValueMap); 565 task.constantCompiler.constantValueMap);
564 } 566 }
565 } 567 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/dart_backend/dart_backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698