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

Unified Diff: lib/compiler/implementation/source_map_builder.dart

Issue 10668029: Associate partial source map with each code block in Universe.generatedCode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
Index: lib/compiler/implementation/source_map_builder.dart
diff --git a/lib/compiler/implementation/source_map_builder.dart b/lib/compiler/implementation/source_map_builder.dart
index 3e5fb6f991deed84d837ca4f90d1a746b3be4055..621a352acc6614e272d537165213fa52d0a9edc9 100644
--- a/lib/compiler/implementation/source_map_builder.dart
+++ b/lib/compiler/implementation/source_map_builder.dart
@@ -7,18 +7,7 @@
#import('dart:json');
#import('source_file.dart');
-
-class SourceMappingEntry {
- SourceFile sourceFile;
- int sourceOffset;
- int targetOffset;
- String sourceName;
-
- SourceMappingEntry(this.sourceFile,
- this.sourceOffset,
- this.targetOffset,
- [this.sourceName]);
-}
+#import('ssa/ssa.dart');
class SourceMapBuilder {
static final int VLQ_BASE_SHIFT = 5;
@@ -28,6 +17,8 @@ class SourceMapBuilder {
static final String BASE64_DIGITS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmn'
'opqrstuvwxyz0123456789+/';
+ List<_Block> blocks;
+
Map<String, int> sourceUrlMap;
List<String> sourceUrlList;
Map<String, int> sourceNameMap;
@@ -42,6 +33,8 @@ class SourceMapBuilder {
bool firstEntryInLine;
SourceMapBuilder() {
+ blocks = new List<_Block>();
+
sourceUrlMap = new Map<String, int>();
sourceUrlList = new List<String>();
sourceNameMap = new Map<String, int>();
@@ -56,13 +49,21 @@ class SourceMapBuilder {
firstEntryInLine = true;
}
- String build(List<SourceMappingEntry> mappingEntries, SourceFile targetFile) {
+ void addCodeBlock(List<SourceMappingEntry> sourceMappings, int offset) {
+ if (sourceMappings !== null) {
+ blocks.add(new _Block(sourceMappings, offset));
+ }
+ }
+
+ String build(SourceFile targetFile) {
StringBuffer buffer = new StringBuffer();
buffer.add('{\n');
buffer.add(' "version": 3,\n');
buffer.add(' "mappings": "');
- mappingEntries.forEach((SourceMappingEntry entry) {
- writeEntry(entry, targetFile, buffer);
+ blocks.forEach((_Block block) {
+ block.sourceMapings.forEach((SourceMappingEntry entry) {
+ writeEntry(entry, targetFile, block.offset, buffer);
+ });
});
buffer.add('",\n');
// TODO(podivilov): serialize lists directly to buffer.
@@ -74,12 +75,14 @@ class SourceMapBuilder {
void writeEntry(SourceMappingEntry entry,
SourceFile targetFile,
+ int targetOffset,
StringBuffer output) {
if (entry.sourceFile === null) {
return;
}
- int targetLine = targetFile.getLine(entry.targetOffset);
- int targetColumn = targetFile.getColumn(targetLine, entry.targetOffset);
+ int totalTargetOffset = targetOffset + entry.targetOffset;
+ int targetLine = targetFile.getLine(totalTargetOffset);
+ int targetColumn = targetFile.getColumn(targetLine, totalTargetOffset);
String sourceUrl = entry.sourceFile.filename;
int sourceLine = entry.sourceFile.getLine(entry.sourceOffset);
int sourceColumn = entry.sourceFile.getColumn(sourceLine,
@@ -149,3 +152,9 @@ class SourceMapBuilder {
} while (value > 0);
}
}
+
+class _Block {
+ List<SourceMappingEntry> sourceMapings;
+ int offset;
+ _Block(this.sourceMapings, this.offset);
+}

Powered by Google App Engine
This is Rietveld 408576698