Chromium Code Reviews| Index: lib/compiler/implementation/ssa/codegen.dart |
| diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart |
| index 81ad82161bd254971a66c369381e174596810a63..220aebe5863445e381bb1ad1d7cdeff3b8ea98dc 100644 |
| --- a/lib/compiler/implementation/ssa/codegen.dart |
| +++ b/lib/compiler/implementation/ssa/codegen.dart |
| @@ -11,7 +11,7 @@ class SsaCodeGeneratorTask extends CompilerTask { |
| NativeEmitter get nativeEmitter() => backend.emitter.nativeEmitter; |
| - String buildJavaScriptFunction(FunctionElement element, |
| + CodeBlock buildJavaScriptFunction(FunctionElement element, |
| String parameters, |
| String body) { |
| String extraSpace = ""; |
| @@ -32,10 +32,19 @@ class SsaCodeGeneratorTask extends CompilerTask { |
| element.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY) { |
| extraSpace = " "; |
| } |
| - return 'function($parameters) {\n$body$extraSpace}'; |
| + |
| + String code = 'function($parameters) {\n$body$extraSpace}'; |
| + List<SourceMappingEntry> sourceMappings = new List<SourceMappingEntry>(); |
| + SourceFile sourceFile = element.getCompilationUnit().script.file; |
| + FunctionExpression expression = element.cachedNode; |
| + sourceMappings.add(new SourceMappingEntry( |
| + sourceFile, expression.getBeginToken().charOffset, 0)); |
| + sourceMappings.add(new SourceMappingEntry( |
| + sourceFile, expression.getEndToken().charOffset, code.length - 1)); |
| + return new CodeBlock(code, sourceMappings); |
| } |
| - String generateMethod(WorkItem work, HGraph graph) { |
| + CodeBlock generateMethod(WorkItem work, HGraph graph) { |
| return measure(() { |
| compiler.tracer.traceGraph("codegen", graph); |
| Map<Element, String> parameterNames = getParameterNames(work); |
| @@ -69,7 +78,7 @@ class SsaCodeGeneratorTask extends CompilerTask { |
| }); |
| } |
| - String generateBailoutMethod(WorkItem work, HGraph graph) { |
| + CodeBlock generateBailoutMethod(WorkItem work, HGraph graph) { |
| return measure(() { |
| compiler.tracer.traceGraph("codegen-bailout", graph); |
| @@ -2929,3 +2938,21 @@ class SsaUnoptimizedCodeGenerator extends SsaCodeGenerator { |
| } |
| } |
| } |
| + |
| +class SourceMappingEntry { |
|
floitsch
2012/07/02 15:18:32
I don't think these classes belong here.
The CodeB
podivilov
2012/07/03 13:08:49
Moved CodeBlock to universe.dart. Please let me kn
|
| + SourceFile sourceFile; |
| + int sourceOffset; |
| + int targetOffset; |
| + String sourceName; |
| + |
| + SourceMappingEntry(this.sourceFile, |
| + this.sourceOffset, |
| + this.targetOffset, |
| + [this.sourceName]); |
| +} |
| + |
| +class CodeBlock { |
| + String code; |
| + List<SourceMappingEntry> sourceMappings; |
| + CodeBlock(this.code, this.sourceMappings); |
| +} |