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

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

Issue 221873002: Compute frontend/backend specific constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart
diff --git a/sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart b/sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart
index fdd9050f60c1a6978796d02fbd4160bbd335da95..94bdc2daa7e5f7517660533dd3baf1e525d62df2 100644
--- a/sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart
+++ b/sdk/lib/_internal/compiler/implementation/dart_backend/backend.dart
@@ -45,6 +45,14 @@ class DartBackend extends Backend {
Map<Element, TreeElements> get resolvedElements =>
compiler.enqueuer.resolution.resolvedElements;
+ ConstantSystem get constantSystem {
+ return constantCompilerTask.constantCompiler.constantSystem;
+ }
+
+ BackendConstantEnvironment get constants => constantCompilerTask;
+
+ DartConstantTask constantCompilerTask;
+
final Set<ClassElement> usedTypeLiterals = new Set<ClassElement>();
/**
@@ -98,6 +106,7 @@ class DartBackend extends Backend {
reexportingLibraries = <Element, LibraryElement>{},
forceStripTypes = strips.indexOf('types') != -1,
stripAsserts = strips.indexOf('asserts') != -1,
+ constantCompilerTask = new DartConstantTask(compiler),
super(compiler);
bool classNeedsRti(ClassElement cls) => false;
@@ -581,3 +590,56 @@ compareElements(e0, e1) {
List<Element> sortElements(Iterable<Element> elements) =>
sorted(elements, compareElements);
+
+/// [ConstantCompilerTask] for compilation of constants for the Dart backend.
+///
+/// Since this task needs no distinction between frontend and backend constants
+/// it also serves as the [BackendConstantEnvironment].
+class DartConstantTask extends ConstantCompilerTask
+ implements BackendConstantEnvironment {
+ final DartConstantCompiler constantCompiler;
+
+ DartConstantTask(Compiler compiler)
+ : this.constantCompiler = new DartConstantCompiler(compiler),
+ super(compiler);
+
+ String get name => 'ConstantHandler';
+
+ Constant getConstantForVariable(VariableElement element) {
+ return constantCompiler.getConstantForVariable(element);
+ }
+
+ Constant getConstantForNode(Node node, TreeElements elements) {
+ return constantCompiler.getConstantForNode(node, elements);
+ }
+
+ Constant getConstantForMetadata(MetadataAnnotation metadata) {
+ return metadata.value;
+ }
+
+ Constant compileConstant(VariableElement element) {
+ return measure(() {
+ return constantCompiler.compileConstant(element);
+ });
+ }
+
+ void compileVariable(VariableElement element) {
+ measure(() {
+ constantCompiler.compileVariable(element);
+ });
+ }
+
+ Constant compileNode(Node node, TreeElements elements) {
+ return measure(() {
+ return constantCompiler.compileNodeWithDefinitions(node, elements);
+ });
+ }
+
+ Constant compileMetadata(MetadataAnnotation metadata,
+ Node node,
+ TreeElements elements) {
+ return measure(() {
+ return constantCompiler.compileMetadata(metadata, node, elements);
+ });
+ }
+}
« 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