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

Side by Side Diff: lib/compiler/implementation/source_map_builder.dart

Issue 10970015: Throw an exception when invalid source file location is encountered. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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('source_map_builder'); 5 #library('source_map_builder');
6 6
7 #import('dart:json'); 7 #import('dart:json');
8 8
9 #import('scanner/scannerlib.dart'); 9 #import('scanner/scannerlib.dart');
10 #import('source_file.dart'); 10 #import('source_file.dart');
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 SourceMapEntry(this.sourceLocation, this.targetOffset); 149 SourceMapEntry(this.sourceLocation, this.targetOffset);
150 } 150 }
151 151
152 class SourceFileLocation { 152 class SourceFileLocation {
153 SourceFile sourceFile; 153 SourceFile sourceFile;
154 Token token; 154 Token token;
155 int line; 155 int line;
156 156
157 SourceFileLocation(this.sourceFile, this.token) { 157 SourceFileLocation(this.sourceFile, this.token) {
158 assert(token.charOffset < sourceFile.text.length); 158 assert(isValid());
159 } 159 }
160 160
161 String getSourceUrl() => sourceFile.filename; 161 String getSourceUrl() => sourceFile.filename;
162 162
163 int getLine() { 163 int getLine() {
164 if (line == null) line = sourceFile.getLine(token.charOffset); 164 if (line == null) line = sourceFile.getLine(token.charOffset);
165 return line; 165 return line;
166 } 166 }
167 167
168 int getColumn() => sourceFile.getColumn(getLine(), token.charOffset); 168 int getColumn() => sourceFile.getColumn(getLine(), token.charOffset);
169 169
170 String getSourceName() { 170 String getSourceName() {
171 if (token.isIdentifier()) return token.slowToString(); 171 if (token.isIdentifier()) return token.slowToString();
172 return null; 172 return null;
173 } 173 }
174
175 bool isValid() => token.charOffset < sourceFile.text.length;
174 } 176 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/builder.dart » ('j') | lib/compiler/implementation/warnings.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698