Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 19359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 19370 JSONObject jsobj(stream); | 19370 JSONObject jsobj(stream); |
| 19371 PrintSharedInstanceJSON(&jsobj, ref); | 19371 PrintSharedInstanceJSON(&jsobj, ref); |
| 19372 jsobj.AddProperty("kind", "List"); | 19372 jsobj.AddProperty("kind", "List"); |
| 19373 jsobj.AddServiceId(*this); | 19373 jsobj.AddServiceId(*this); |
| 19374 jsobj.AddProperty("length", Length()); | 19374 jsobj.AddProperty("length", Length()); |
| 19375 if (ref) { | 19375 if (ref) { |
| 19376 return; | 19376 return; |
| 19377 } | 19377 } |
| 19378 { | 19378 { |
| 19379 JSONArray jsarr(&jsobj, "elements"); | 19379 JSONArray jsarr(&jsobj, "elements"); |
| 19380 Object& element = Object::Handle(); | |
|
koda
2015/06/02 16:42:37
Thanks for fixing this.
| |
| 19380 for (intptr_t index = 0; index < Length(); index++) { | 19381 for (intptr_t index = 0; index < Length(); index++) { |
| 19381 JSONObject jselement(&jsarr); | 19382 JSONObject jselement(&jsarr); |
| 19382 jselement.AddProperty("index", index); | 19383 jselement.AddProperty("index", index); |
| 19383 | 19384 |
| 19384 Object& element = Object::Handle(At(index)); | 19385 element = At(index); |
| 19385 jselement.AddProperty("value", element); | 19386 jselement.AddProperty("value", element); |
| 19386 } | 19387 } |
| 19387 } | 19388 } |
| 19388 } | 19389 } |
| 19389 | 19390 |
| 19390 | 19391 |
| 19391 RawArray* Array::Grow(const Array& source, | 19392 RawArray* Array::Grow(const Array& source, |
| 19392 intptr_t new_length, | 19393 intptr_t new_length, |
| 19393 Heap::Space space) { | 19394 Heap::Space space) { |
| 19394 Isolate* isolate = Isolate::Current(); | 19395 Isolate* isolate = Isolate::Current(); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 19616 JSONObject jsobj(stream); | 19617 JSONObject jsobj(stream); |
| 19617 PrintSharedInstanceJSON(&jsobj, ref); | 19618 PrintSharedInstanceJSON(&jsobj, ref); |
| 19618 jsobj.AddProperty("kind", "List"); | 19619 jsobj.AddProperty("kind", "List"); |
| 19619 jsobj.AddServiceId(*this); | 19620 jsobj.AddServiceId(*this); |
| 19620 jsobj.AddProperty("length", Length()); | 19621 jsobj.AddProperty("length", Length()); |
| 19621 if (ref) { | 19622 if (ref) { |
| 19622 return; | 19623 return; |
| 19623 } | 19624 } |
| 19624 { | 19625 { |
| 19625 JSONArray jsarr(&jsobj, "elements"); | 19626 JSONArray jsarr(&jsobj, "elements"); |
| 19627 Object& element = Object::Handle(); | |
| 19626 for (intptr_t index = 0; index < Length(); index++) { | 19628 for (intptr_t index = 0; index < Length(); index++) { |
| 19627 JSONObject jselement(&jsarr); | 19629 JSONObject jselement(&jsarr); |
| 19628 jselement.AddProperty("index", index); | 19630 jselement.AddProperty("index", index); |
| 19629 | 19631 |
| 19630 Object& element = Object::Handle(At(index)); | 19632 element = At(index); |
| 19631 jselement.AddProperty("value", element); | 19633 jselement.AddProperty("value", element); |
| 19632 } | 19634 } |
| 19633 } | 19635 } |
| 19634 } | 19636 } |
| 19635 | 19637 |
| 19636 | 19638 |
| 19637 // Equivalent to Dart's operator "==" and hashCode. | 19639 // Equivalent to Dart's operator "==" and hashCode. |
| 19638 class DefaultHashTraits { | 19640 class DefaultHashTraits { |
| 19639 public: | 19641 public: |
| 19640 static bool IsMatch(const Object& a, const Object& b) { | 19642 static bool IsMatch(const Object& a, const Object& b) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 19713 LinkedHashMap::InstanceSize(), | 19715 LinkedHashMap::InstanceSize(), |
| 19714 space); | 19716 space); |
| 19715 NoSafepointScope no_safepoint; | 19717 NoSafepointScope no_safepoint; |
| 19716 result ^= raw; | 19718 result ^= raw; |
| 19717 } | 19719 } |
| 19718 return result.raw(); | 19720 return result.raw(); |
| 19719 } | 19721 } |
| 19720 | 19722 |
| 19721 | 19723 |
| 19722 const char* LinkedHashMap::ToCString() const { | 19724 const char* LinkedHashMap::ToCString() const { |
| 19723 // TODO(koda): Print key/value pairs. | 19725 const char* format = "_LinkedHashMap len:%" Pd; |
| 19724 return "_LinkedHashMap"; | 19726 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; |
|
koda
2015/06/02 16:42:36
Use Thread::Current()->zone()->PrintToString(...)
rmacnak
2015/06/02 17:33:31
Much nicer. Updated Array::ToCString as well.
| |
| 19727 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | |
| 19728 OS::SNPrint(chars, len, format, Length()); | |
| 19729 return chars; | |
| 19725 } | 19730 } |
| 19726 | 19731 |
| 19727 | 19732 |
| 19728 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19733 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 19729 JSONObject jsobj(stream); | 19734 JSONObject jsobj(stream); |
| 19730 PrintSharedInstanceJSON(&jsobj, ref); | 19735 PrintSharedInstanceJSON(&jsobj, ref); |
| 19731 jsobj.AddProperty("kind", "Map"); | 19736 jsobj.AddProperty("kind", "Map"); |
| 19732 jsobj.AddServiceId(*this); | 19737 jsobj.AddServiceId(*this); |
| 19733 // TODO(koda): Print length. | 19738 jsobj.AddProperty("length", Length()); |
| 19734 if (ref) { | 19739 if (ref) { |
| 19735 return; | 19740 return; |
| 19736 } | 19741 } |
| 19737 // TODO(koda): Print key/value pairs. | 19742 { |
| 19743 JSONArray jsarr(&jsobj, "associations"); | |
| 19744 Object& object = Object::Handle(); | |
| 19745 LinkedHashMap::Iterator iterator(*this); | |
| 19746 while (iterator.MoveNext()) { | |
| 19747 JSONObject jsassoc(&jsarr); | |
| 19748 object = iterator.CurrentKey(); | |
| 19749 jsassoc.AddProperty("key", object); | |
| 19750 object = iterator.CurrentValue(); | |
| 19751 jsassoc.AddProperty("value", object); | |
| 19752 } | |
| 19753 } | |
| 19738 } | 19754 } |
| 19739 | 19755 |
| 19740 | 19756 |
| 19741 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, | 19757 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, |
| 19742 Heap::Space space) { | 19758 Heap::Space space) { |
| 19743 ASSERT(Isolate::Current()->object_store()->float32x4_class() != | 19759 ASSERT(Isolate::Current()->object_store()->float32x4_class() != |
| 19744 Class::null()); | 19760 Class::null()); |
| 19745 Float32x4& result = Float32x4::Handle(); | 19761 Float32x4& result = Float32x4::Handle(); |
| 19746 { | 19762 { |
| 19747 RawObject* raw = Object::Allocate(Float32x4::kClassId, | 19763 RawObject* raw = Object::Allocate(Float32x4::kClassId, |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 20820 return tag_label.ToCString(); | 20836 return tag_label.ToCString(); |
| 20821 } | 20837 } |
| 20822 | 20838 |
| 20823 | 20839 |
| 20824 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20840 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20825 Instance::PrintJSONImpl(stream, ref); | 20841 Instance::PrintJSONImpl(stream, ref); |
| 20826 } | 20842 } |
| 20827 | 20843 |
| 20828 | 20844 |
| 20829 } // namespace dart | 20845 } // namespace dart |
| OLD | NEW |