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 ffd3a8b95940ec729d808c55609d1d9b6503aa09..cc9a11579c1ebdcd6c929e69cf60a1f52710c2e8 100644 |
| --- a/lib/compiler/implementation/ssa/codegen.dart |
| +++ b/lib/compiler/implementation/ssa/codegen.dart |
| @@ -18,13 +18,17 @@ class SsaCodeGeneratorTask extends CompilerTask { |
| js.Block body) { |
| FunctionExpression expression = element.cachedNode; |
| js.Fun result = new js.Fun(parameters, body); |
| - result.sourcePosition = expression.getBeginToken(); |
| - result.endSourcePosition = expression.getEndToken(); |
| + Element sourceElement = element.patch == null ? element : element.patch; |
|
ahe
2012/09/08 08:55:50
Another TODO for Johnni.
podivilov
2012/09/10 11:13:23
Done.
|
| + SourceFile sourceFile = sourceElement.getCompilationUnit().script.file; |
| + result.sourcePosition = new SourceFileLocation( |
| + sourceFile, expression.getBeginToken()); |
| + result.endSourcePosition = new SourceFileLocation( |
| + sourceFile, expression.getEndToken()); |
| return result; |
| } |
| - CodeBuffer prettyPrint(js.Node node, Element positionElement) { |
| - return js.prettyPrint(node, compiler, positionElement); |
| + CodeBuffer prettyPrint(js.Node node) { |
| + return js.prettyPrint(node, compiler); |
| } |
| CodeBuffer generateCode(WorkItem work, HGraph graph) { |
| @@ -43,9 +47,8 @@ class SsaCodeGeneratorTask extends CompilerTask { |
| backend, work, parameters, new Map<Element, String>()); |
| codegen.visitGraph(graph); |
| js.Block body = codegen.body; |
| - Element element = work.element; |
| js.Fun fun = new js.Fun(parameters, body); |
| - return prettyPrint(fun, element); |
| + return prettyPrint(fun); |
| }); |
| } |
| @@ -88,7 +91,7 @@ class SsaCodeGeneratorTask extends CompilerTask { |
| // and needs to know if the method is overridden. |
| nativeEmitter.overriddenMethods.add(element); |
| StringBuffer buffer = new StringBuffer(); |
| - String codeString = prettyPrint(codegen.body, work.element).toString(); |
| + String codeString = prettyPrint(codegen.body).toString(); |
| native.generateMethodWithPrototypeCheckForElement( |
| compiler, buffer, element, codeString, parametersString); |
| js.Node nativeCode = new js.LiteralStatement(buffer.toString()); |
| @@ -97,7 +100,7 @@ class SsaCodeGeneratorTask extends CompilerTask { |
| body = codegen.body; |
| } |
| js.Fun fun = buildJavaScriptFunction(element, parameters, body); |
| - return prettyPrint(fun, work.element); |
| + return prettyPrint(fun); |
| }); |
| } |
| @@ -140,7 +143,7 @@ class SsaCodeGeneratorTask extends CompilerTask { |
| body.statements.add(codegen.body); |
| js.Fun fun = |
| buildJavaScriptFunction(work.element, codegen.newParameters, body); |
| - return prettyPrint(fun, work.element); |
| + return prettyPrint(fun); |
| }); |
| } |
| @@ -338,15 +341,15 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| } |
| js.Node attachLocation(js.Node jsNode, HInstruction instruction) { |
| - if (instruction.sourcePosition !== null) { |
| - jsNode.sourcePosition = instruction.sourcePosition; |
| - } |
| + jsNode.sourcePosition = instruction.sourcePosition; |
| return jsNode; |
| } |
| - js.Node attachLocationRange(js.Node jsNode, Node node) { |
| - jsNode.sourcePosition = node.getBeginToken(); |
| - jsNode.endSourcePosition = node.getEndToken(); |
| + js.Node attachLocationRange(js.Node jsNode, |
| + SourceFileLocation sourcePosition, |
| + SourceFileLocation endSourcePosition) { |
| + jsNode.sourcePosition = sourcePosition; |
| + jsNode.endSourcePosition = endSourcePosition; |
| return jsNode; |
| } |
| @@ -930,7 +933,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { |
| 'Unexpected loop kind: ${info.kind}', |
| instruction: condition.conditionExpression); |
| } |
| - attachLocationRange(loop, info.sourcePosition); |
| + attachLocationRange(loop, info.sourcePosition, info.endSourcePosition); |
| pushStatement(wrapIntoLabels(loop, info.labels)); |
| return true; |
| } |
| @@ -2585,7 +2588,9 @@ class SsaOptimizedCodeGenerator extends SsaCodeGenerator { |
| js.While loop = new js.While(new js.LiteralBool(true), body); |
| HLoopInformation info = block.loopInformation; |
| - attachLocationRange(loop, info.loopBlockInformation.sourcePosition); |
| + attachLocationRange(loop, |
| + info.loopBlockInformation.sourcePosition, |
| + info.loopBlockInformation.endSourcePosition); |
| pushStatement(wrapIntoLabels(loop, info.labels)); |
| } |
| @@ -2839,7 +2844,9 @@ class SsaUnoptimizedCodeGenerator extends SsaCodeGenerator { |
| currentContainer = oldContainerStack.removeLast(); |
| js.Statement result = new js.While(new js.LiteralBool(true), body); |
| - attachLocationRange(result, info.loopBlockInformation.sourcePosition); |
| + attachLocationRange(result, |
| + info.loopBlockInformation.sourcePosition, |
| + info.loopBlockInformation.endSourcePosition); |
| result = new js.LabeledStatement(loopLabel, result); |
| result = wrapIntoLabels(result, info.labels); |
| pushStatement(result); |