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

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

Issue 23526056: Make Dart_ScriptGetTokenInfo account for line_offset() and col_offset() (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comment Created 7 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
« no previous file with comments | « runtime/include/dart_debugger_api.h ('k') | tools/coverage.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 "include/dart_debugger_api.h" 5 #include "include/dart_debugger_api.h"
6 6
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_api_state.h" 10 #include "vm/dart_api_state.h"
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 CURRENT_FUNC, script_url.ToCString(), 683 CURRENT_FUNC, script_url.ToCString(),
684 String::Handle(lib.url()).ToCString()); 684 String::Handle(lib.url()).ToCString());
685 } 685 }
686 686
687 const GrowableObjectArray& info = 687 const GrowableObjectArray& info =
688 GrowableObjectArray::Handle(GrowableObjectArray::New()); 688 GrowableObjectArray::Handle(GrowableObjectArray::New());
689 const String& source = String::Handle(script.Source()); 689 const String& source = String::Handle(script.Source());
690 const String& key = Symbols::Empty(); 690 const String& key = Symbols::Empty();
691 const Object& line_separator = Object::Handle(); 691 const Object& line_separator = Object::Handle();
692 const TokenStream& tkns = TokenStream::Handle(script.tokens()); 692 const TokenStream& tkns = TokenStream::Handle(script.tokens());
693 int line_offset = script.line_offset();
693 ASSERT(!tkns.IsNull()); 694 ASSERT(!tkns.IsNull());
694 TokenStream::Iterator tkit(tkns, 0); 695 TokenStream::Iterator tkit(tkns, 0);
695 int current_line = -1; 696 int current_line = -1;
696 Scanner s(source, key); 697 Scanner s(source, key);
697 s.Scan(); 698 s.Scan();
698 while (s.current_token().kind != Token::kEOS) { 699 while (s.current_token().kind != Token::kEOS) {
699 ASSERT(tkit.IsValid()); 700 ASSERT(tkit.IsValid());
700 ASSERT(s.current_token().kind == tkit.CurrentTokenKind()); 701 ASSERT(s.current_token().kind == tkit.CurrentTokenKind());
701 int token_line = s.current_token().position.line; 702 int token_line = s.current_token().position.line;
702 if (token_line != current_line) { 703 if (token_line != current_line) {
703 // emit line 704 // emit line
704 info.Add(line_separator); 705 info.Add(line_separator);
705 info.Add(Smi::Handle(Smi::New(token_line))); 706 info.Add(Smi::Handle(Smi::New(token_line + line_offset)));
706 current_line = token_line; 707 current_line = token_line;
707 } 708 }
708 // TODO(hausner): Could optimize here by not reporting tokens 709 // TODO(hausner): Could optimize here by not reporting tokens
709 // that will never be a location used by the debugger, e.g. 710 // that will never be a location used by the debugger, e.g.
710 // braces, semicolons, most keywords etc. 711 // braces, semicolons, most keywords etc.
711 info.Add(Smi::Handle(Smi::New(tkit.CurrentPosition()))); 712 info.Add(Smi::Handle(Smi::New(tkit.CurrentPosition())));
712 info.Add(Smi::Handle(Smi::New(s.current_token().offset))); 713 int column = s.current_token().position.column;
714 // On the first line of the script we must add the column offset.
715 if (token_line == 1) {
716 column += script.col_offset();
717 }
718 info.Add(Smi::Handle(Smi::New(column)));
713 s.Scan(); 719 s.Scan();
714 tkit.Advance(); 720 tkit.Advance();
715 } 721 }
716 return Api::NewHandle(isolate, Array::MakeArray(info)); 722 return Api::NewHandle(isolate, Array::MakeArray(info));
717 } 723 }
718 724
719 725
720 DART_EXPORT Dart_Handle Dart_GenerateScriptSource(Dart_Handle library_url_in, 726 DART_EXPORT Dart_Handle Dart_GenerateScriptSource(Dart_Handle library_url_in,
721 Dart_Handle script_url_in) { 727 Dart_Handle script_url_in) {
722 Isolate* isolate = Isolate::Current(); 728 Isolate* isolate = Isolate::Current();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 897
892 898
893 DART_EXPORT char* Dart_GetVmStatus(const char* request) { 899 DART_EXPORT char* Dart_GetVmStatus(const char* request) {
894 if (strncmp(request, "/isolate/", 9) == 0) { 900 if (strncmp(request, "/isolate/", 9) == 0) {
895 return Isolate::GetStatus(request); 901 return Isolate::GetStatus(request);
896 } 902 }
897 return NULL; 903 return NULL;
898 } 904 }
899 905
900 } // namespace dart 906 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/include/dart_debugger_api.h ('k') | tools/coverage.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698