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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart

Issue 251593006: Functional JavaScript AST source position updates (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js/nodes.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
index 638b0b52bfeabf82458b4288955b5d65f7d5a5d0..290764580e504d8c8bae94f3bed5af191cdc4c7a 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
@@ -31,15 +31,14 @@ class SsaCodeGeneratorTask extends CompilerTask {
}
// TODO(podivilov): find the right sourceFile here and remove offset
// checks below.
+ var sourcePosition, endSourcePosition;
if (beginToken.charOffset < sourceFile.length) {
- node.sourcePosition =
- new TokenSourceFileLocation(sourceFile, beginToken);
+ sourcePosition = new TokenSourceFileLocation(sourceFile, beginToken);
}
if (endToken.charOffset < sourceFile.length) {
- node.endSourcePosition =
- new TokenSourceFileLocation(sourceFile, endToken);
+ endSourcePosition = new TokenSourceFileLocation(sourceFile, endToken);
}
- return node;
+ return node.withPosition(sourcePosition, endSourcePosition);
}
SourceFile sourceFileOfElement(Element element) {
@@ -204,7 +203,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
void pushStatement(js.Statement statement, [HInstruction instruction]) {
assert(expressionStack.isEmpty);
if (instruction != null) {
- attachLocation(statement, instruction);
+ statement = attachLocation(statement, instruction);
}
currentContainer.statements.add(statement);
}
@@ -228,7 +227,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
*/
push(js.Expression expression, [HInstruction instruction]) {
if (instruction != null) {
- attachLocation(expression, instruction);
+ expression = attachLocation(expression, instruction);
}
expressionStack.add(expression);
}
@@ -238,20 +237,19 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
}
attachLocationToLast(HInstruction instruction) {
- attachLocation(expressionStack.last, instruction);
+ int index = expressionStack.length - 1;
+ expressionStack[index] =
+ attachLocation(expressionStack[index], instruction);
}
js.Node attachLocation(js.Node jsNode, HInstruction instruction) {
- jsNode.sourcePosition = instruction.sourcePosition;
- return jsNode;
+ return jsNode.withLocation(instruction.sourcePosition);
}
js.Node attachLocationRange(js.Node jsNode,
SourceFileLocation sourcePosition,
SourceFileLocation endSourcePosition) {
- jsNode.sourcePosition = sourcePosition;
- jsNode.endSourcePosition = endSourcePosition;
- return jsNode;
+ return jsNode.withPosition(sourcePosition, endSourcePosition);
}
void preGenerateMethod(HGraph graph) {
@@ -920,8 +918,8 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
compiler.internalError(condition.conditionExpression,
'Unexpected loop kind: ${info.kind}.');
}
- attachLocationRange(loop, info.sourcePosition, info.endSourcePosition);
- js.Statement result = loop;
+ js.Statement result =
+ attachLocationRange(loop, info.sourcePosition, info.endSourcePosition);
if (info.kind == HLoopBlockInformation.SWITCH_CONTINUE_LOOP) {
String continueLabelString =
backend.namer.implicitContinueLabelName(info.target);
@@ -2001,7 +1999,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
arguments.add(pop());
}
js.Call value = new js.Call(jsHelper, arguments);
- attachLocation(value, location);
+ value = attachLocation(value, location);
// BUG(4906): Using throw/return here adds to the size of the generated code
// but it has the advantage of explicitly telling the JS engine that
// this code path will terminate abruptly. Needs more work.
@@ -2022,7 +2020,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
js.VariableUse jsHelper =
new js.VariableUse(backend.namer.isolateAccess(helper));
js.Call value = new js.Call(jsHelper, [pop()]);
- attachLocation(value, argument);
+ value = attachLocation(value, argument);
push(value, node);
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js/nodes.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698