Index: pkg/compiler/lib/src/io/position_information.dart |
diff --git a/pkg/compiler/lib/src/io/position_information.dart b/pkg/compiler/lib/src/io/position_information.dart |
index 896676389d84d665dc5d383c39a3c4bd332eb5f5..1a561cdff8299abce1b025de3cc595a669531a28 100644 |
--- a/pkg/compiler/lib/src/io/position_information.dart |
+++ b/pkg/compiler/lib/src/io/position_information.dart |
@@ -163,7 +163,8 @@ class PositionSourceInformationBuilder implements SourceInformationBuilder { |
sourceFile, element.position.charOffset, name)); |
} else { |
return new PositionSourceInformation( |
- null, |
+ new OffsetSourceLocation(sourceFile, |
+ element.resolvedAst.node.getBeginToken().charOffset, name), |
new OffsetSourceLocation(sourceFile, |
element.resolvedAst.node.getEndToken().charOffset, name)); |
} |
@@ -500,16 +501,30 @@ class PositionTraceListener extends TraceListener with |
void onStep(js.Node node, Offset offset, StepKind kind) { |
SourceInformation sourceInformation = computeSourceInformation(node); |
if (sourceInformation == null) return; |
+ int codeLocation = offset.subexpressionOffset; |
+ if (codeLocation == null) return; |
+ |
+ void registerPosition(SourcePositionKind sourcePositionKind) { |
+ SourceLocation sourceLocation = |
+ getSourceLocation(sourceInformation, sourcePositionKind); |
+ if (sourceLocation != null) { |
+ sourceMapper.register(node, codeLocation, sourceLocation); |
+ } |
+ } |
- SourcePositionKind sourcePositionKind = SourcePositionKind.START; |
switch (kind) { |
- case StepKind.FUN: |
- sourcePositionKind = SourcePositionKind.INNER; |
+ case StepKind.FUN_ENTRY: |
+ // TODO(johnniwinther): Remove this when fully transitioned to the |
+ // new source info system. |
+ registerPosition(SourcePositionKind.START); |
+ break; |
+ case StepKind.FUN_EXIT: |
+ registerPosition(SourcePositionKind.INNER); |
break; |
case StepKind.CALL: |
CallPosition callPosition = |
CallPosition.getSemanticPositionForCall(node); |
- sourcePositionKind = callPosition.sourcePositionKind; |
+ registerPosition(callPosition.sourcePositionKind); |
break; |
case StepKind.NEW: |
case StepKind.RETURN: |
@@ -524,14 +539,9 @@ class PositionTraceListener extends TraceListener with |
case StepKind.WHILE_CONDITION: |
case StepKind.DO_CONDITION: |
case StepKind.SWITCH_EXPRESSION: |
+ registerPosition(SourcePositionKind.START); |
break; |
} |
- int codeLocation = offset.subexpressionOffset; |
- SourceLocation sourceLocation = |
- getSourceLocation(sourceInformation, sourcePositionKind); |
- if (codeLocation != null && sourceLocation != null) { |
- sourceMapper.register(node, codeLocation, sourceLocation); |
- } |
} |
} |
@@ -672,7 +682,8 @@ enum BranchKind { |
} |
enum StepKind { |
- FUN, |
+ FUN_ENTRY, |
+ FUN_EXIT, |
CALL, |
NEW, |
RETURN, |
@@ -797,11 +808,17 @@ class JavaScriptTracer extends js.BaseVisitor { |
if (!active) { |
active = node.sourceInformation != null; |
} |
+ leftToRightOffset = statementOffset = |
+ getSyntaxOffset(node, kind: CodePositionKind.START); |
+ Offset entryOffset = getOffsetForNode(node, statementOffset); |
+ notifyStep(node, entryOffset, StepKind.FUN_ENTRY); |
+ |
visit(node.body); |
+ |
leftToRightOffset = statementOffset = |
getSyntaxOffset(node, kind: CodePositionKind.CLOSING); |
- Offset offset = getOffsetForNode(node, statementOffset); |
- notifyStep(node, offset, StepKind.FUN); |
+ Offset exitOffset = getOffsetForNode(node, statementOffset); |
+ notifyStep(node, exitOffset, StepKind.FUN_EXIT); |
active = activeBefore; |
} |