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

Unified Diff: pkg/compiler/lib/src/js/js_source_mapping.dart

Issue 1196433002: Create and test source mapping for invocations. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 years, 6 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/js/js_debug.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js/js_source_mapping.dart
diff --git a/pkg/compiler/lib/src/js/js_source_mapping.dart b/pkg/compiler/lib/src/js/js_source_mapping.dart
new file mode 100644
index 0000000000000000000000000000000000000000..0378a58b1ef85e8d4050e9572aa9be13c6f0a835
--- /dev/null
+++ b/pkg/compiler/lib/src/js/js_source_mapping.dart
@@ -0,0 +1,68 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library js.source_mapping;
+
+import 'js.dart';
+import '../io/code_output.dart' show SourceLocations;
+import '../io/source_information.dart' show
+ SourceLocation,
+ SourceInformation,
+ SourceInformationStrategy;
+
+/// [SourceInformationStrategy] that can associate source information with
+/// JavaScript output.
+class JavaScriptSourceInformationStrategy
+ extends SourceInformationStrategy {
+ const JavaScriptSourceInformationStrategy();
+
+ /// Creates a processor that can associate source information on [Node] with
+ /// code offsets in the [sourceMapper].
+ SourceInformationProcessor createProcessor(SourceMapper sourceMapper) {
+ return const SourceInformationProcessor();
+ }
+}
+
+/// An observer of code positions of printed JavaScript [Node]s.
+class CodePositionListener {
+ const CodePositionListener();
+
+ /// Called to associate [node] with the provided start, end and closing
+ /// positions.
+ void onPositions(
+ Node node,
+ int startPosition,
+ int endPosition,
+ int closingPosition) {}
+}
+
+/// An interface for mapping code offsets with [SourceLocation]s for JavaScript
+/// [Node]s.
+abstract class SourceMapper {
+ /// Associate [codeOffset] with [sourceLocation] for [node].
+ void register(Node node, int codeOffset, SourceLocation sourceLocation);
+}
+
+/// An implementation of [SourceMapper] that stores the information directly
+/// into a [SourceLocations] object.
+class SourceLocationsMapper implements SourceMapper {
+ final SourceLocations sourceLocations;
+
+ SourceLocationsMapper(this.sourceLocations);
+
+ @override
+ void register(Node node, int codeOffset, SourceLocation sourceLocation) {
+ sourceLocations.addSourceLocation(codeOffset, sourceLocation);
+ }
+}
+
+/// A processor that associates [SourceInformation] with code position of
+/// JavaScript [Node]s.
+class SourceInformationProcessor extends CodePositionListener {
+ const SourceInformationProcessor();
+
+ /// Process the source information and code positions for the [node] and all
+ /// its children.
+ void process(Node node) {}
+}
« no previous file with comments | « pkg/compiler/lib/src/js/js_debug.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698