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

Unified Diff: lib/compiler/implementation/compiler.dart

Issue 10697003: Various token issues fixed in the compiler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merged Created 8 years, 6 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
Index: lib/compiler/implementation/compiler.dart
diff --git a/lib/compiler/implementation/compiler.dart b/lib/compiler/implementation/compiler.dart
index 7da90baf06fdd271888a85a5197a9e503fdb9df6..1a96d78e43d0bee975916db0ef1440e0c017b197 100644
--- a/lib/compiler/implementation/compiler.dart
+++ b/lib/compiler/implementation/compiler.dart
@@ -781,8 +781,8 @@ class Compiler implements DiagnosticListener {
new SourceSpan(uri, beginOffset, endOffset));
}
- SourceSpan spanFromNode(Node node) {
- return spanFromTokens(node.getBeginToken(), node.getEndToken());
+ SourceSpan spanFromNode(Node node, [Uri uri]) {
+ return spanFromTokens(node.getBeginToken(), node.getEndToken(), uri);
}
SourceSpan spanFromElement(Element element) {
@@ -879,15 +879,11 @@ class SourceSpan {
static withOffsets(Token begin, Token end,
Lasse Reichstein Nielsen 2012/06/27 09:22:16 withOffsets -> withCharacterOffsets ?
f(int beginOffset, int endOffset)) {
final beginOffset = begin.charOffset;
- // TODO(ahe): Compute proper end offset in token. Right now we use
- // the position of the next token. We want to preserve the
- // invariant that endOffset > beginOffset, but for EOF the
- // charoffset of the next token may be [beginOffset]. This can
- // also happen for synthetized tokens that are produced during
- // error handling.
- final endOffset =
- Math.max((end.next !== null) ? end.next.charOffset : 0, beginOffset + 1);
- assert(endOffset > beginOffset);
+ final endOffset = end.charOffset + end.slowCharLength;
Lasse Reichstein Nielsen 2012/06/27 09:22:16 slowCharLength -> slowCharCount
+
+ // [begin] and [end] might be the same empty token. This happens for
Lasse Reichstein Nielsen 2012/06/27 09:22:16 "the same empty token" -> "the same for the empty
+ // instance when parsing '$$'.
Lasse Reichstein Nielsen 2012/06/27 09:22:16 parsing -> scanning.
+ assert(endOffset >= beginOffset);
return f(beginOffset, endOffset);
}
}
« no previous file with comments | « no previous file | lib/compiler/implementation/elements/elements.dart » ('j') | lib/compiler/implementation/elements/elements.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698