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

Side by Side 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, 5 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
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
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.
4
5 library js.source_mapping;
6
7 import 'js.dart';
8 import '../io/code_output.dart' show SourceLocations;
9 import '../io/source_information.dart' show
10 SourceLocation,
11 SourceInformation,
12 SourceInformationStrategy;
13
14 /// [SourceInformationStrategy] that can associate source information with
15 /// JavaScript output.
16 class JavaScriptSourceInformationStrategy
17 extends SourceInformationStrategy {
18 const JavaScriptSourceInformationStrategy();
19
20 /// Creates a processor that can associate source information on [Node] with
21 /// code offsets in the [sourceMapper].
22 SourceInformationProcessor createProcessor(SourceMapper sourceMapper) {
23 return const SourceInformationProcessor();
24 }
25 }
26
27 /// An observer of code positions of printed JavaScript [Node]s.
28 class CodePositionListener {
29 const CodePositionListener();
30
31 /// Called to associate [node] with the provided start, end and closing
32 /// positions.
33 void onPositions(
34 Node node,
35 int startPosition,
36 int endPosition,
37 int closingPosition) {}
38 }
39
40 /// An interface for mapping code offsets with [SourceLocation]s for JavaScript
41 /// [Node]s.
42 abstract class SourceMapper {
43 /// Associate [codeOffset] with [sourceLocation] for [node].
44 void register(Node node, int codeOffset, SourceLocation sourceLocation);
45 }
46
47 /// An implementation of [SourceMapper] that stores the information directly
48 /// into a [SourceLocations] object.
49 class SourceLocationsMapper implements SourceMapper {
50 final SourceLocations sourceLocations;
51
52 SourceLocationsMapper(this.sourceLocations);
53
54 @override
55 void register(Node node, int codeOffset, SourceLocation sourceLocation) {
56 sourceLocations.addSourceLocation(codeOffset, sourceLocation);
57 }
58 }
59
60 /// A processor that associates [SourceInformation] with code position of
61 /// JavaScript [Node]s.
62 class SourceInformationProcessor extends CodePositionListener {
63 const SourceInformationProcessor();
64
65 /// Process the source information and code positions for the [node] and all
66 /// its children.
67 void process(Node node) {}
68 }
OLDNEW
« 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