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

Unified Diff: pkg/compiler/lib/src/io/source_information.dart

Issue 955543004: Pass SourceInformation through the CPS IR. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix tests. Created 5 years, 10 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 | « pkg/compiler/lib/src/io/code_output.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/io/source_information.dart
diff --git a/pkg/compiler/lib/src/io/source_information.dart b/pkg/compiler/lib/src/io/source_information.dart
index c238268db6ffb80ed9d94f8dd7bab46f06ffa7c6..6ee34e6f7645a9fb25854d633b08043fc9102476 100644
--- a/pkg/compiler/lib/src/io/source_information.dart
+++ b/pkg/compiler/lib/src/io/source_information.dart
@@ -95,14 +95,57 @@ class StartEndSourceInformation implements SourceInformation {
String toString() {
StringBuffer sb = new StringBuffer();
sb.write('${startPosition.sourceUri}:');
- sb.write('[${startPosition.line},${startPosition.column}]');
+ // Use 1-based line/column info to match usual dart tool output.
+ sb.write('[${startPosition.line + 1},${startPosition.column + 1}]');
if (endPosition != null) {
- sb.write('-[${endPosition.line},${endPosition.column}]');
+ sb.write('-[${endPosition.line + 1},${endPosition.column + 1}]');
}
return sb.toString();
}
}
+/// [SourceInformation] that consists of an offset position into the source
+/// code.
+class PositionSourceInformation implements SourceInformation {
+ final SourceLocation sourcePosition;
+
+ PositionSourceInformation(this.sourcePosition);
+
+ @override
+ void beginMapping(CodeOutput output) {
+ output.setSourceLocation(sourcePosition);
+ }
+
+ @override
+ void endMapping(CodeOutput output) {
+ // Do nothing.
+ }
+
+ SourceSpan get sourceSpan {
+ Uri uri = sourcePosition.sourceUri;
+ int offset = sourcePosition.offset;
+ return new SourceSpan(uri, offset, offset);
+ }
+
+ int get hashCode {
+ return sourcePosition.hashCode * 17 & 0x7FFFFFFF;
+ }
+
+ bool operator ==(other) {
+ if (identical(this, other)) return true;
+ if (other is! PositionSourceInformation) return false;
+ return sourcePosition == other.sourcePosition;
+ }
+
+ String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.write('${sourcePosition.sourceUri}:');
+ // Use 1-based line/column info to match usual dart tool output.
+ sb.write('[${sourcePosition.line + 1},${sourcePosition.column + 1}]');
+ return sb.toString();
+ }
+}
+
/// A location in a source file.
abstract class SourceLocation {
final SourceFile _sourceFile;
@@ -147,7 +190,10 @@ abstract class SourceLocation {
sourceName == other.sourceName;
}
- String toString() => '${sourceUri}:[${line},${column}]';
+ String toString() {
+ // Use 1-based line/column info to match usual dart tool output.
+ return '${sourceUri}:[${line + 1},${column + 1}]';
+ }
}
class TokenSourceLocation extends SourceLocation {
« no previous file with comments | « pkg/compiler/lib/src/io/code_output.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698