Chromium Code Reviews| Index: lib/compiler/implementation/emitter.dart |
| diff --git a/lib/compiler/implementation/emitter.dart b/lib/compiler/implementation/emitter.dart |
| index 3121e1fec87ce642397f0941394cb56826f79d59..9cd1a50fcea4deb5a43b9d21577859343019c6de 100644 |
| --- a/lib/compiler/implementation/emitter.dart |
| +++ b/lib/compiler/implementation/emitter.dart |
| @@ -38,6 +38,7 @@ class CodeEmitterTask extends CompilerTask { |
| boundClosureBuffer = new StringBuffer(), |
| mainBuffer = new StringBuffer(), |
| boundClosureCache = new Map<int, String>(), |
| + sourceMappings = new List<SourceMappingEntry>(), |
| super(compiler) { |
| nativeEmitter = new NativeEmitter(this); |
| } |
| @@ -597,7 +598,12 @@ function() { |
| generatedCode.forEach((Element element, String codeBlock) { |
| if (!element.isInstanceMember()) { |
| String functionName = functionNamer(element); |
| - buffer.add('$isolateProperties.$functionName = $codeBlock;\n\n'); |
| + buffer.add('$isolateProperties.$functionName = '); |
| + int beginPosition = buffer.length; |
| + buffer.add(codeBlock); |
| + int endPosition = buffer.length; |
| + buffer.add(';\n\n'); |
| + addSourceMapping(element, beginPosition, endPosition); |
| } |
| }); |
| } |
| @@ -1006,4 +1012,13 @@ if (typeof window != 'undefined' && typeof document != 'undefined' && |
| }); |
| return compiler.assembledCode; |
| } |
| + |
| + void addSourceMapping(FunctionElement element, int emittedBeginPosition, int emittedEndPosition) { |
|
podivilov
2012/06/19 16:37:54
This should probably be a method of SourceMapListe
ahe
2012/06/19 17:00:41
Long lines.
podivilov
2012/06/20 09:37:14
Done.
|
| + SourceFile sourceFile = element.getCompilationUnit().script.file; |
| + FunctionExpression expression = element.cachedNode; |
| + sourceMappings.add(new SourceMappingEntry(sourceFile, expression.getBeginToken().charOffset, emittedBeginPosition)); |
| + sourceMappings.add(new SourceMappingEntry(sourceFile, expression.getEndToken().charOffset, emittedEndPosition)); |
| + } |
| + |
| + final List<SourceMappingEntry> sourceMappings; |
| } |