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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart

Issue 226953003: Revert "Compute frontend/backend specific constants." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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) 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 27 matching lines...) Expand all
38 /// Initialized when dart:mirrors is loaded if the useMirrorHelperLibrary 38 /// Initialized when dart:mirrors is loaded if the useMirrorHelperLibrary
39 /// field is set. 39 /// field is set.
40 FunctionElement mirrorHelperGetNameFunction; 40 FunctionElement mirrorHelperGetNameFunction;
41 /// Initialized when dart:mirrors is loaded if the useMirrorHelperLibrary 41 /// Initialized when dart:mirrors is loaded if the useMirrorHelperLibrary
42 /// field is set. 42 /// field is set.
43 Element mirrorHelperSymbolsMap; 43 Element mirrorHelperSymbolsMap;
44 44
45 Map<Element, TreeElements> get resolvedElements => 45 Map<Element, TreeElements> get resolvedElements =>
46 compiler.enqueuer.resolution.resolvedElements; 46 compiler.enqueuer.resolution.resolvedElements;
47 47
48 ConstantSystem get constantSystem {
49 return constantCompilerTask.constantCompiler.constantSystem;
50 }
51
52 BackendConstantEnvironment get constants => constantCompilerTask;
53
54 DartConstantTask constantCompilerTask;
55
56 final Set<ClassElement> usedTypeLiterals = new Set<ClassElement>(); 48 final Set<ClassElement> usedTypeLiterals = new Set<ClassElement>();
57 49
58 /** 50 /**
59 * Tells whether it is safe to remove type declarations from variables, 51 * Tells whether it is safe to remove type declarations from variables,
60 * functions parameters. It becomes not safe if: 52 * functions parameters. It becomes not safe if:
61 * 1) TypeError is used somewhere in the code, 53 * 1) TypeError is used somewhere in the code,
62 * 2) The code has typedefs in right hand side of IS checks, 54 * 2) The code has typedefs in right hand side of IS checks,
63 * 3) The code has classes which extend typedefs, have type arguments typedefs 55 * 3) The code has classes which extend typedefs, have type arguments typedefs
64 * or type variable bounds typedefs. 56 * or type variable bounds typedefs.
65 * These restrictions can be less strict. 57 * These restrictions can be less strict.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 91 }
100 92
101 DartBackend(Compiler compiler, List<String> strips) 93 DartBackend(Compiler compiler, List<String> strips)
102 : tasks = <CompilerTask>[], 94 : tasks = <CompilerTask>[],
103 renames = new Map<Node, String>(), 95 renames = new Map<Node, String>(),
104 imports = new Map<LibraryElement, String>(), 96 imports = new Map<LibraryElement, String>(),
105 memberNodes = new Map<ClassNode, List<Node>>(), 97 memberNodes = new Map<ClassNode, List<Node>>(),
106 reexportingLibraries = <Element, LibraryElement>{}, 98 reexportingLibraries = <Element, LibraryElement>{},
107 forceStripTypes = strips.indexOf('types') != -1, 99 forceStripTypes = strips.indexOf('types') != -1,
108 stripAsserts = strips.indexOf('asserts') != -1, 100 stripAsserts = strips.indexOf('asserts') != -1,
109 constantCompilerTask = new DartConstantTask(compiler),
110 super(compiler); 101 super(compiler);
111 102
112 bool classNeedsRti(ClassElement cls) => false; 103 bool classNeedsRti(ClassElement cls) => false;
113 bool methodNeedsRti(FunctionElement function) => false; 104 bool methodNeedsRti(FunctionElement function) => false;
114 105
115 void enqueueHelpers(ResolutionEnqueuer world, TreeElements elements) { 106 void enqueueHelpers(ResolutionEnqueuer world, TreeElements elements) {
116 // Right now resolver doesn't always resolve interfaces needed 107 // Right now resolver doesn't always resolve interfaces needed
117 // for literals, so force them. TODO(antonm): fix in the resolver. 108 // for literals, so force them. TODO(antonm): fix in the resolver.
118 final LITERAL_TYPE_NAMES = const [ 109 final LITERAL_TYPE_NAMES = const [
119 'Map', 'List', 'num', 'int', 'double', 'bool' 110 'Map', 'List', 'num', 'int', 'double', 'bool'
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 } 574 }
584 575
585 compareElements(e0, e1) { 576 compareElements(e0, e1) {
586 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); 577 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1);
587 if (result != 0) return result; 578 if (result != 0) return result;
588 return compareBy((e) => e.position().charOffset)(e0, e1); 579 return compareBy((e) => e.position().charOffset)(e0, e1);
589 } 580 }
590 581
591 List<Element> sortElements(Iterable<Element> elements) => 582 List<Element> sortElements(Iterable<Element> elements) =>
592 sorted(elements, compareElements); 583 sorted(elements, compareElements);
593
594 /// [ConstantCompilerTask] for compilation of constants for the Dart backend.
595 ///
596 /// Since this task needs no distinction between frontend and backend constants
597 /// it also serves as the [BackendConstantEnvironment].
598 class DartConstantTask extends ConstantCompilerTask
599 implements BackendConstantEnvironment {
600 final DartConstantCompiler constantCompiler;
601
602 DartConstantTask(Compiler compiler)
603 : this.constantCompiler = new DartConstantCompiler(compiler),
604 super(compiler);
605
606 String get name => 'ConstantHandler';
607
608 Constant getConstantForVariable(VariableElement element) {
609 return constantCompiler.getConstantForVariable(element);
610 }
611
612 Constant getConstantForNode(Node node, TreeElements elements) {
613 return constantCompiler.getConstantForNode(node, elements);
614 }
615
616 Constant getConstantForMetadata(MetadataAnnotation metadata) {
617 return metadata.value;
618 }
619
620 Constant compileConstant(VariableElement element) {
621 return measure(() {
622 return constantCompiler.compileConstant(element);
623 });
624 }
625
626 void compileVariable(VariableElement element) {
627 measure(() {
628 constantCompiler.compileVariable(element);
629 });
630 }
631
632 Constant compileNode(Node node, TreeElements elements) {
633 return measure(() {
634 return constantCompiler.compileNodeWithDefinitions(node, elements);
635 });
636 }
637
638 Constant compileMetadata(MetadataAnnotation metadata,
639 Node node,
640 TreeElements elements) {
641 return measure(() {
642 return constantCompiler.compileMetadata(metadata, node, elements);
643 });
644 }
645 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/compiler.dart ('k') | sdk/lib/_internal/compiler/implementation/deferred_load.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698