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

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

Issue 1644793002: Replace intptr_t with TokenDescriptor (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "platform/assert.h" 5 #include "platform/assert.h"
6 6
7 #include "vm/dart_entry.h" 7 #include "vm/dart_entry.h"
8 #include "vm/debugger.h" 8 #include "vm/debugger.h"
9 #include "vm/json_stream.h" 9 #include "vm/json_stream.h"
10 #include "vm/message.h" 10 #include "vm/message.h"
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 va_end(args); 742 va_end(args);
743 ASSERT(len == len2); 743 ASSERT(len == len2);
744 stream_->buffer_.AddChar('"'); 744 stream_->buffer_.AddChar('"');
745 stream_->AddEscapedUTF8String(p); 745 stream_->AddEscapedUTF8String(p);
746 stream_->buffer_.AddChar('"'); 746 stream_->buffer_.AddChar('"');
747 free(p); 747 free(p);
748 } 748 }
749 749
750 750
751 void JSONObject::AddLocation(const Script& script, 751 void JSONObject::AddLocation(const Script& script,
752 intptr_t token_pos, 752 TokenDescriptor token_pos,
753 intptr_t end_token_pos) const { 753 TokenDescriptor end_token_pos) const {
754 JSONObject location(this, "location"); 754 JSONObject location(this, "location");
755 location.AddProperty("type", "SourceLocation"); 755 location.AddProperty("type", "SourceLocation");
756 location.AddProperty("script", script); 756 location.AddProperty("script", script);
757 location.AddProperty("tokenPos", token_pos); 757 location.AddProperty("tokenPos", token_pos.value());
758 if (end_token_pos >= 0) { 758 if (end_token_pos.IsReal()) {
759 location.AddProperty("endTokenPos", end_token_pos); 759 location.AddProperty("endTokenPos", end_token_pos.value());
760 } 760 }
761 } 761 }
762 762
763 763
764 void JSONObject::AddLocation(const BreakpointLocation* bpt_loc) const { 764 void JSONObject::AddLocation(const BreakpointLocation* bpt_loc) const {
765 ASSERT(bpt_loc->IsResolved()); 765 ASSERT(bpt_loc->IsResolved());
766 766
767 Zone* zone = Thread::Current()->zone(); 767 Zone* zone = Thread::Current()->zone();
768 Library& library = Library::Handle(zone); 768 Library& library = Library::Handle(zone);
769 Script& script = Script::Handle(zone); 769 Script& script = Script::Handle(zone);
770 intptr_t token_pos; 770 TokenDescriptor token_pos = TokenDescriptor::kNoSource;
771 bpt_loc->GetCodeLocation(&library, &script, &token_pos); 771 bpt_loc->GetCodeLocation(&library, &script, &token_pos);
772 AddLocation(script, token_pos); 772 AddLocation(script, token_pos);
773 } 773 }
774 774
775 775
776 void JSONObject::AddUnresolvedLocation( 776 void JSONObject::AddUnresolvedLocation(
777 const BreakpointLocation* bpt_loc) const { 777 const BreakpointLocation* bpt_loc) const {
778 ASSERT(!bpt_loc->IsResolved()); 778 ASSERT(!bpt_loc->IsResolved());
779 779
780 Zone* zone = Thread::Current()->zone(); 780 Zone* zone = Thread::Current()->zone();
781 Library& library = Library::Handle(zone); 781 Library& library = Library::Handle(zone);
782 Script& script = Script::Handle(zone); 782 Script& script = Script::Handle(zone);
783 intptr_t token_pos; 783 TokenDescriptor token_pos = TokenDescriptor::kNoSource;
784 bpt_loc->GetCodeLocation(&library, &script, &token_pos); 784 bpt_loc->GetCodeLocation(&library, &script, &token_pos);
785 785
786 JSONObject location(this, "location"); 786 JSONObject location(this, "location");
787 location.AddProperty("type", "UnresolvedSourceLocation"); 787 location.AddProperty("type", "UnresolvedSourceLocation");
788 if (!script.IsNull()) { 788 if (!script.IsNull()) {
789 location.AddProperty("script", script); 789 location.AddProperty("script", script);
790 } else { 790 } else {
791 const String& scriptUri = String::Handle(zone, bpt_loc->url()); 791 const String& scriptUri = String::Handle(zone, bpt_loc->url());
792 location.AddPropertyStr("scriptUri", scriptUri); 792 location.AddPropertyStr("scriptUri", scriptUri);
793 } 793 }
794 if (bpt_loc->requested_line_number() >= 0) { 794 if (bpt_loc->requested_line_number() >= 0) {
795 // This unresolved breakpoint was specified at a particular line. 795 // This unresolved breakpoint was specified at a particular line.
796 location.AddProperty("line", bpt_loc->requested_line_number()); 796 location.AddProperty("line", bpt_loc->requested_line_number());
797 if (bpt_loc->requested_column_number() >= 0) { 797 if (bpt_loc->requested_column_number() >= 0) {
798 location.AddProperty("column", 798 location.AddProperty("column",
799 bpt_loc->requested_column_number()); 799 bpt_loc->requested_column_number());
800 } 800 }
801 } else { 801 } else {
802 // This unresolved breakpoint was requested at some function entry. 802 // This unresolved breakpoint was requested at some function entry.
803 location.AddProperty("tokenPos", token_pos); 803 location.AddProperty("tokenPos", token_pos.value());
804 } 804 }
805 } 805 }
806 806
807 807
808 void JSONObject::AddPropertyF(const char* name, 808 void JSONObject::AddPropertyF(const char* name,
809 const char* format, ...) const { 809 const char* format, ...) const {
810 stream_->PrintPropertyName(name); 810 stream_->PrintPropertyName(name);
811 va_list args; 811 va_list args;
812 va_start(args, format); 812 va_start(args, format);
813 intptr_t len = OS::VSNPrint(NULL, 0, format, args); 813 intptr_t len = OS::VSNPrint(NULL, 0, format, args);
(...skipping 21 matching lines...) Expand all
835 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); 835 intptr_t len2 = OS::VSNPrint(p, len+1, format, args);
836 va_end(args); 836 va_end(args);
837 ASSERT(len == len2); 837 ASSERT(len == len2);
838 stream_->buffer_.AddChar('"'); 838 stream_->buffer_.AddChar('"');
839 stream_->AddEscapedUTF8String(p); 839 stream_->AddEscapedUTF8String(p);
840 stream_->buffer_.AddChar('"'); 840 stream_->buffer_.AddChar('"');
841 free(p); 841 free(p);
842 } 842 }
843 843
844 } // namespace dart 844 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698