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

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

Issue 11273041: Make first and last getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files with co19 issue number. Created 8 years, 1 month 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_file'); 5 #library('source_file');
6 6
7 #import('dart:math'); 7 #import('dart:math');
8 8
9 #import('colors.dart', prefix: 'colors'); 9 #import('colors.dart', prefix: 'colors');
10 10
(...skipping 22 matching lines...) Expand all
33 starts.add(index); 33 starts.add(index);
34 } 34 }
35 starts.add(text.length + 1); 35 starts.add(text.length + 1);
36 _lineStarts = starts; 36 _lineStarts = starts;
37 } 37 }
38 return _lineStarts; 38 return _lineStarts;
39 } 39 }
40 40
41 int getLine(int position) { 41 int getLine(int position) {
42 List<int> starts = lineStarts; 42 List<int> starts = lineStarts;
43 if (position < 0 || starts.last() <= position) { 43 if (position < 0 || starts.last <= position) {
44 throw 'bad position #$position in file $filename with ' 44 throw 'bad position #$position in file $filename with '
45 'length ${text.length}.'; 45 'length ${text.length}.';
46 } 46 }
47 int first = 0; 47 int first = 0;
48 int count = starts.length; 48 int count = starts.length;
49 while (count > 1) { 49 while (count > 1) {
50 int step = count ~/ 2; 50 int step = count ~/ 2;
51 int middle = first + step; 51 int middle = first + step;
52 int lineStart = starts[middle]; 52 int lineStart = starts[middle];
53 if (position < lineStart) { 53 if (position < lineStart) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 97
98 for (; i < toColumn; i++) { 98 for (; i < toColumn; i++) {
99 buf.add(color('^')); 99 buf.add(color('^'));
100 } 100 }
101 } 101 }
102 102
103 return buf.toString(); 103 return buf.toString();
104 } 104 }
105 } 105 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/lib/interceptors.dart ('k') | lib/compiler/implementation/ssa/bailout.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698