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

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

Issue 10686003: Better breakpoint placement (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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/vm/object.h ('k') | runtime/vm/scanner.h » ('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 "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 4510 matching lines...) Expand 10 before | Expand all | Expand 10 after
4521 intptr_t* column) const { 4521 intptr_t* column) const {
4522 const String& src = String::Handle(source()); 4522 const String& src = String::Handle(source());
4523 const String& dummy_key = String::Handle(String::New("")); 4523 const String& dummy_key = String::Handle(String::New(""));
4524 Scanner scanner(src, dummy_key); 4524 Scanner scanner(src, dummy_key);
4525 scanner.ScanTo(token_pos); 4525 scanner.ScanTo(token_pos);
4526 *line = scanner.CurrentPosition().line; 4526 *line = scanner.CurrentPosition().line;
4527 *column = scanner.CurrentPosition().column; 4527 *column = scanner.CurrentPosition().column;
4528 } 4528 }
4529 4529
4530 4530
4531 intptr_t Script::TokenIndexAtLine(intptr_t line_number) const { 4531 void Script::TokenRangeAtLine(intptr_t line_number,
4532 intptr_t* first_token_index,
4533 intptr_t* last_token_index) const {
4532 const String& src = String::Handle(source()); 4534 const String& src = String::Handle(source());
4533 const String& dummy_key = String::Handle(String::New("")); 4535 const String& dummy_key = String::Handle(String::New(""));
4534 Scanner scanner(src, dummy_key); 4536 Scanner scanner(src, dummy_key);
4535 return scanner.TokenIndexAtLine(line_number); 4537 scanner.TokenRangeAtLine(line_number, first_token_index, last_token_index);
4536 } 4538 }
4537 4539
4538 4540
4539 RawString* Script::GetLine(intptr_t line_number) const { 4541 RawString* Script::GetLine(intptr_t line_number) const {
4540 const String& src = String::Handle(source()); 4542 const String& src = String::Handle(source());
4541 intptr_t current_line = 1; 4543 intptr_t current_line = 1;
4542 intptr_t line_start = -1; 4544 intptr_t line_start = -1;
4543 intptr_t last_char = -1; 4545 intptr_t last_char = -1;
4544 for (intptr_t ix = 0; 4546 for (intptr_t ix = 0;
4545 (ix < src.Length()) && (current_line <= line_number); 4547 (ix < src.Length()) && (current_line <= line_number);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
4687 Object& obj = Object::Handle(array_.At(next_ix_)); 4689 Object& obj = Object::Handle(array_.At(next_ix_));
4688 while (!obj.IsClass() && HasNext()) { 4690 while (!obj.IsClass() && HasNext()) {
4689 next_ix_++; 4691 next_ix_++;
4690 obj = array_.At(next_ix_); 4692 obj = array_.At(next_ix_);
4691 } 4693 }
4692 } 4694 }
4693 4695
4694 4696
4695 LibraryPrefixIterator::LibraryPrefixIterator(const Library& library) 4697 LibraryPrefixIterator::LibraryPrefixIterator(const Library& library)
4696 : DictionaryIterator(library) { 4698 : DictionaryIterator(library) {
4697 MoveToNext(); 4699 Advance();
4698 } 4700 }
4699 4701
4700 4702
4701 RawLibraryPrefix* LibraryPrefixIterator::GetNext() { 4703 RawLibraryPrefix* LibraryPrefixIterator::GetNext() {
4702 ASSERT(HasNext()); 4704 ASSERT(HasNext());
4703 int ix = next_ix_++; 4705 int ix = next_ix_++;
4704 Object& obj = Object::Handle(array_.At(ix)); 4706 Object& obj = Object::Handle(array_.At(ix));
4705 MoveToNext(); 4707 Advance();
4706 LibraryPrefix& prefix = LibraryPrefix::Handle(); 4708 LibraryPrefix& prefix = LibraryPrefix::Handle();
4707 prefix ^= obj.raw(); 4709 prefix ^= obj.raw();
4708 return prefix.raw(); 4710 return prefix.raw();
4709 } 4711 }
4710 4712
4711 4713
4712 void LibraryPrefixIterator::MoveToNext() { 4714 void LibraryPrefixIterator::Advance() {
4713 Object& obj = Object::Handle(array_.At(next_ix_)); 4715 Object& obj = Object::Handle(array_.At(next_ix_));
4714 while (!obj.IsLibraryPrefix() && HasNext()) { 4716 while (!obj.IsLibraryPrefix() && HasNext()) {
4715 next_ix_++; 4717 next_ix_++;
4716 obj = array_.At(next_ix_); 4718 obj = array_.At(next_ix_);
4717 } 4719 }
4718 } 4720 }
4719 4721
4720 4722
4721 void Library::SetName(const String& name) const { 4723 void Library::SetName(const String& name) const {
4722 // Only set name once. 4724 // Only set name once.
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
4919 4921
4920 RawFunction* Library::LookupFunctionInSource(const String& script_url, 4922 RawFunction* Library::LookupFunctionInSource(const String& script_url,
4921 intptr_t line_number) const { 4923 intptr_t line_number) const {
4922 Script& script = Script::Handle(LookupScript(script_url)); 4924 Script& script = Script::Handle(LookupScript(script_url));
4923 if (script.IsNull()) { 4925 if (script.IsNull()) {
4924 // The given script url is not loaded into this library. 4926 // The given script url is not loaded into this library.
4925 return Function::null(); 4927 return Function::null();
4926 } 4928 }
4927 4929
4928 // Determine token position at given line number. 4930 // Determine token position at given line number.
4929 intptr_t token_pos_at_line = script.TokenIndexAtLine(line_number); 4931 intptr_t first_token_pos, last_token_pos;
4930 if (token_pos_at_line < 0) { 4932 script.TokenRangeAtLine(line_number, &first_token_pos, &last_token_pos);
4933 if (first_token_pos < 0) {
4931 // Script does not contain the given line number. 4934 // Script does not contain the given line number.
4932 return Function::null(); 4935 return Function::null();
4933 } 4936 }
4934 4937 return LookupFunctionInScript(script, first_token_pos);
4935 return LookupFunctionInScript(script, token_pos_at_line);
4936 } 4938 }
4937 4939
4938 4940
4939 RawFunction* Library::LookupFunctionInScript(const Script& script, 4941 RawFunction* Library::LookupFunctionInScript(const Script& script,
4940 intptr_t token_pos) const { 4942 intptr_t token_pos) const {
4941 Class& cls = Class::Handle(); 4943 Class& cls = Class::Handle();
4942 Function& func = Function::Handle(); 4944 Function& func = Function::Handle();
4943 ClassDictionaryIterator it(*this); 4945 ClassDictionaryIterator it(*this);
4944 while (it.HasNext()) { 4946 while (it.HasNext()) {
4945 cls = it.GetNextClass(); 4947 cls = it.GetNextClass();
(...skipping 5296 matching lines...) Expand 10 before | Expand all | Expand 10 after
10242 const String& str = String::Handle(pattern()); 10244 const String& str = String::Handle(pattern());
10243 const char* format = "JSRegExp: pattern=%s flags=%s"; 10245 const char* format = "JSRegExp: pattern=%s flags=%s";
10244 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 10246 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
10245 char* chars = reinterpret_cast<char*>( 10247 char* chars = reinterpret_cast<char*>(
10246 Isolate::Current()->current_zone()->Allocate(len + 1)); 10248 Isolate::Current()->current_zone()->Allocate(len + 1));
10247 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 10249 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
10248 return chars; 10250 return chars;
10249 } 10251 }
10250 10252
10251 } // namespace dart 10253 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698