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

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

Issue 1653183002: getObject now supports specifying offset,count for strings. (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
« no previous file with comments | « runtime/vm/json_test.cc ('k') | runtime/vm/object_test.cc » ('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 20189 matching lines...) Expand 10 before | Expand all | Expand 10 after
20200 // special string in their program. Fixing this involves updating 20200 // special string in their program. Fixing this involves updating
20201 // the debugging api a bit. 20201 // the debugging api a bit.
20202 jsobj.AddProperty("type", "Sentinel"); 20202 jsobj.AddProperty("type", "Sentinel");
20203 jsobj.AddProperty("kind", "OptimizedOut"); 20203 jsobj.AddProperty("kind", "OptimizedOut");
20204 jsobj.AddProperty("valueAsString", "<optimized out>"); 20204 jsobj.AddProperty("valueAsString", "<optimized out>");
20205 return; 20205 return;
20206 } 20206 }
20207 PrintSharedInstanceJSON(&jsobj, ref); 20207 PrintSharedInstanceJSON(&jsobj, ref);
20208 jsobj.AddProperty("kind", "String"); 20208 jsobj.AddProperty("kind", "String");
20209 jsobj.AddServiceId(*this); 20209 jsobj.AddServiceId(*this);
20210 jsobj.AddProperty("length", Length());
20210 if (ref) { 20211 if (ref) {
20211 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this, 128); 20212 // String refs always truncate to a fixed count;
20212 if (did_truncate) { 20213 const intptr_t kFixedCount = 128;
20213 jsobj.AddProperty("valueAsStringIsTruncated", did_truncate); 20214 if (jsobj.AddPropertyStr("valueAsString", *this, 0, kFixedCount)) {
20215 jsobj.AddProperty("count", kFixedCount);
20216 jsobj.AddProperty("valueAsStringIsTruncated", true);
20214 } 20217 }
20215 } else { 20218 return;
20216 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this);
20217 ASSERT(!did_truncate);
20218 } 20219 }
20220
20221 intptr_t offset;
20222 intptr_t count;
20223 stream->ComputeOffsetAndCount(Length(), &offset, &count);
20224 if (offset > 0) {
20225 jsobj.AddProperty("offset", offset);
20226 }
20227 if (count < Length()) {
20228 jsobj.AddProperty("count", count);
20229 }
20230 jsobj.AddPropertyStr("valueAsString", *this, offset, count);
20219 } 20231 }
20220 20232
20221 20233
20222 void String::ToUTF8(uint8_t* utf8_array, intptr_t array_len) const { 20234 void String::ToUTF8(uint8_t* utf8_array, intptr_t array_len) const {
20223 ASSERT(array_len >= Utf8::Length(*this)); 20235 ASSERT(array_len >= Utf8::Length(*this));
20224 Utf8::Encode(*this, reinterpret_cast<char*>(utf8_array), array_len); 20236 Utf8::Encode(*this, reinterpret_cast<char*>(utf8_array), array_len);
20225 } 20237 }
20226 20238
20227 20239
20228 static FinalizablePersistentHandle* AddFinalizer( 20240 static FinalizablePersistentHandle* AddFinalizer(
(...skipping 2608 matching lines...) Expand 10 before | Expand all | Expand 10 after
22837 return tag_label.ToCString(); 22849 return tag_label.ToCString();
22838 } 22850 }
22839 22851
22840 22852
22841 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 22853 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
22842 Instance::PrintJSONImpl(stream, ref); 22854 Instance::PrintJSONImpl(stream, ref);
22843 } 22855 }
22844 22856
22845 22857
22846 } // namespace dart 22858 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/json_test.cc ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698