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

Side by Side Diff: runtime/vm/object.cc

Issue 1066203004: Fix MethodMirror.source when the method is on the first line in a script. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | tests/lib/mirrors/method_mirror_source_other.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 8409 matching lines...) Expand 10 before | Expand all | Expand 10 after
8420 intptr_t line = 1 + line_offset(); 8420 intptr_t line = 1 + line_offset();
8421 intptr_t column = 1; 8421 intptr_t column = 1;
8422 intptr_t scan_position = 0; 8422 intptr_t scan_position = 0;
8423 intptr_t snippet_start = -1; 8423 intptr_t snippet_start = -1;
8424 intptr_t snippet_end = -1; 8424 intptr_t snippet_end = -1;
8425 if (from_line - line_offset() == 1) { 8425 if (from_line - line_offset() == 1) {
8426 column += col_offset(); 8426 column += col_offset();
8427 } 8427 }
8428 8428
8429 while (scan_position != length) { 8429 while (scan_position != length) {
8430 if (snippet_start == -1) {
8431 if ((line == from_line) && (column == from_column)) {
8432 snippet_start = scan_position;
8433 }
8434 }
8435
8430 char c = src.CharAt(scan_position); 8436 char c = src.CharAt(scan_position);
8431 if (c == '\n') { 8437 if (c == '\n') {
8432 line++; 8438 line++;
8433 column = 0; 8439 column = 0;
8434 } else if (c == '\r') { 8440 } else if (c == '\r') {
8435 line++; 8441 line++;
8436 column = 0; 8442 column = 0;
8437 if ((scan_position + 1 != length) && 8443 if ((scan_position + 1 != length) &&
8438 (src.CharAt(scan_position + 1) == '\n')) { 8444 (src.CharAt(scan_position + 1) == '\n')) {
8439 scan_position++; 8445 scan_position++;
8440 } 8446 }
8441 } 8447 }
8442 scan_position++; 8448 scan_position++;
8443 column++; 8449 column++;
8444 8450
8445 if (snippet_start == -1) { 8451 if ((line == to_line) && (column == to_column)) {
8446 if ((line == from_line) && (column == from_column)) {
8447 snippet_start = scan_position;
8448 }
8449 } else if ((line == to_line) && (column == to_column)) {
8450 snippet_end = scan_position; 8452 snippet_end = scan_position;
8451 break; 8453 break;
8452 } 8454 }
8453 } 8455 }
8454 String& snippet = String::Handle(); 8456 String& snippet = String::Handle();
8455 if ((snippet_start != -1) && (snippet_end != -1)) { 8457 if ((snippet_start != -1) && (snippet_end != -1)) {
8456 snippet = 8458 snippet =
8457 String::SubString(src, snippet_start, snippet_end - snippet_start); 8459 String::SubString(src, snippet_start, snippet_end - snippet_start);
8458 } 8460 }
8459 return snippet.raw(); 8461 return snippet.raw();
(...skipping 12265 matching lines...) Expand 10 before | Expand all | Expand 10 after
20725 return tag_label.ToCString(); 20727 return tag_label.ToCString();
20726 } 20728 }
20727 20729
20728 20730
20729 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20731 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20730 Instance::PrintJSONImpl(stream, ref); 20732 Instance::PrintJSONImpl(stream, ref);
20731 } 20733 }
20732 20734
20733 20735
20734 } // namespace dart 20736 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/lib/mirrors/method_mirror_source_other.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698