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

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart

Issue 1100723002: Add SourceInformationFactory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 5 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
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/dart2jslib.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
index e786e17a8bd25413cb9e335306f7ed8aae7a59ce..8934cbe320707e37da8ae87cce82d0cf677eba15 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart
@@ -12,7 +12,6 @@ import '../dart2jslib.dart';
import '../elements/elements.dart';
import '../elements/modelx.dart' show SynthesizedConstructorElementX,
ConstructorBodyElementX, FunctionSignatureX;
-import '../io/source_file.dart';
import '../io/source_information.dart';
import '../js_backend/js_backend.dart' show JavaScriptBackend;
import '../resolution/semantic_visitor.dart';
@@ -42,11 +41,11 @@ import 'cps_ir_builder.dart';
*/
class IrBuilderTask extends CompilerTask {
final Map<Element, ir.RootNode> nodes = <Element, ir.RootNode>{};
- final bool generateSourceMap;
+ final SourceInformationFactory sourceInformationFactory;
String bailoutMessage = null;
- IrBuilderTask(Compiler compiler, {this.generateSourceMap: true})
+ IrBuilderTask(Compiler compiler, this.sourceInformationFactory)
: super(compiler);
String get name => 'IR builder';
@@ -67,9 +66,8 @@ class IrBuilderTask extends CompilerTask {
TreeElements elementsMapping = element.resolvedAst.elements;
element = element.implementation;
return compiler.withCurrentElement(element, () {
- SourceInformationBuilder sourceInformationBuilder = generateSourceMap
- ? new PositionSourceInformationBuilder(element)
- : const SourceInformationBuilder();
+ SourceInformationBuilder sourceInformationBuilder =
+ sourceInformationFactory.forContext(element);
IrBuilderVisitor builder =
compiler.backend is JavaScriptBackend
@@ -2761,47 +2759,6 @@ class JsIrBuilderVisitor extends IrBuilderVisitor {
}
}
-/// Interface for generating [SourceInformation] for the CPS.
-class SourceInformationBuilder {
- const SourceInformationBuilder();
-
- /// Create a [SourceInformationBuilder] for [element].
- SourceInformationBuilder forContext(AstElement element) => this;
-
- /// Generate [SourceInformation] for the read access in [node].
- SourceInformation buildGet(ast.Node node) => null;
-
- /// Generate [SourceInformation] for the invocation in [node].
- SourceInformation buildCall(ast.Node node) => null;
-}
-
-/// [SourceInformationBuilder] that generates [PositionSourceInformation].
-class PositionSourceInformationBuilder implements SourceInformationBuilder {
- final SourceFile sourceFile;
- final String name;
-
- PositionSourceInformationBuilder(AstElement element)
- : sourceFile = element.compilationUnit.script.file,
- name = element.name;
-
- @override
- SourceInformation buildGet(ast.Node node) {
- return new PositionSourceInformation(
- new TokenSourceLocation(sourceFile, node.getBeginToken(), name));
- }
-
- @override
- SourceInformation buildCall(ast.Node node) {
- return new PositionSourceInformation(
- new TokenSourceLocation(sourceFile, node.getBeginToken(), name));
- }
-
- @override
- SourceInformationBuilder forContext(AstElement element) {
- return new PositionSourceInformationBuilder(element);
- }
-}
-
/// Perform simple post-processing on the initial CPS-translated root term.
///
/// This pass performs backend-independent post-processing on the translated
@@ -2868,4 +2825,3 @@ class RemovalVisitor extends ir.RecursiveVisitor {
reference.unlink();
}
}
-
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/dart2jslib.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698