| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.source_map_builder; | 5 library dart2js.source_map_builder; |
| 6 | 6 |
| 7 import '../util/util.dart'; | 7 import '../util/util.dart'; |
| 8 import '../scanner/scannerlib.dart' show Token; | |
| 9 import '../util/uri_extras.dart' show relativize; | 8 import '../util/uri_extras.dart' show relativize; |
| 10 import 'line_column_provider.dart'; | 9 import 'line_column_provider.dart'; |
| 11 import 'source_file.dart'; | 10 import 'source_information.dart' show SourceFileLocation; |
| 12 | 11 |
| 13 class SourceMapBuilder { | 12 class SourceMapBuilder { |
| 14 static const int VLQ_BASE_SHIFT = 5; | 13 static const int VLQ_BASE_SHIFT = 5; |
| 15 static const int VLQ_BASE_MASK = (1 << 5) - 1; | 14 static const int VLQ_BASE_MASK = (1 << 5) - 1; |
| 16 static const int VLQ_CONTINUATION_BIT = 1 << 5; | 15 static const int VLQ_CONTINUATION_BIT = 1 << 5; |
| 17 static const int VLQ_CONTINUATION_MASK = 1 << 5; | 16 static const int VLQ_CONTINUATION_MASK = 1 << 5; |
| 18 static const String BASE64_DIGITS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmn' | 17 static const String BASE64_DIGITS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmn' |
| 19 'opqrstuvwxyz0123456789+/'; | 18 'opqrstuvwxyz0123456789+/'; |
| 20 | 19 |
| 21 final Uri uri; | 20 final Uri uri; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } while (value > 0); | 222 } while (value > 0); |
| 224 } | 223 } |
| 225 } | 224 } |
| 226 | 225 |
| 227 class SourceMapEntry { | 226 class SourceMapEntry { |
| 228 SourceFileLocation sourceLocation; | 227 SourceFileLocation sourceLocation; |
| 229 int targetOffset; | 228 int targetOffset; |
| 230 | 229 |
| 231 SourceMapEntry(this.sourceLocation, this.targetOffset); | 230 SourceMapEntry(this.sourceLocation, this.targetOffset); |
| 232 } | 231 } |
| 233 | |
| 234 abstract class SourceFileLocation { | |
| 235 SourceFile sourceFile; | |
| 236 | |
| 237 SourceFileLocation(this.sourceFile) { | |
| 238 assert(isValid()); | |
| 239 } | |
| 240 | |
| 241 int line; | |
| 242 | |
| 243 int get offset; | |
| 244 | |
| 245 String getSourceUrl() => sourceFile.filename; | |
| 246 | |
| 247 int getLine() { | |
| 248 if (line == null) line = sourceFile.getLine(offset); | |
| 249 return line; | |
| 250 } | |
| 251 | |
| 252 int getColumn() => sourceFile.getColumn(getLine(), offset); | |
| 253 | |
| 254 String getSourceName(); | |
| 255 | |
| 256 bool isValid() => offset < sourceFile.length; | |
| 257 } | |
| 258 | |
| 259 class TokenSourceFileLocation extends SourceFileLocation { | |
| 260 final Token token; | |
| 261 final String name; | |
| 262 | |
| 263 TokenSourceFileLocation(SourceFile sourceFile, this.token, this.name) | |
| 264 : super(sourceFile); | |
| 265 | |
| 266 int get offset => token.charOffset; | |
| 267 | |
| 268 String getSourceName() { | |
| 269 return name; | |
| 270 } | |
| 271 } | |
| OLD | NEW |