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 5900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5911 void Field::PrintToJSONStream(JSONStream* stream, bool ref) const { | 5911 void Field::PrintToJSONStream(JSONStream* stream, bool ref) const { |
5912 JSONObject jsobj(stream); | 5912 JSONObject jsobj(stream); |
5913 const char* internal_field_name = String::Handle(name()).ToCString(); | 5913 const char* internal_field_name = String::Handle(name()).ToCString(); |
5914 const char* field_name = String::Handle(UserVisibleName()).ToCString(); | 5914 const char* field_name = String::Handle(UserVisibleName()).ToCString(); |
5915 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 5915 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
5916 intptr_t id = ring->GetIdForObject(raw()); | 5916 intptr_t id = ring->GetIdForObject(raw()); |
5917 jsobj.AddProperty("type", JSONType(ref)); | 5917 jsobj.AddProperty("type", JSONType(ref)); |
5918 jsobj.AddProperty("id", id); | 5918 jsobj.AddProperty("id", id); |
5919 jsobj.AddProperty("name", internal_field_name); | 5919 jsobj.AddProperty("name", internal_field_name); |
5920 jsobj.AddProperty("user_name", field_name); | 5920 jsobj.AddProperty("user_name", field_name); |
| 5921 if (is_static()) { |
| 5922 const Object& valueObj = Object::Handle(value()); |
| 5923 jsobj.AddProperty("value", valueObj); |
| 5924 } |
| 5925 Class& cls = Class::Handle(owner()); |
| 5926 jsobj.AddProperty("owner", cls); |
| 5927 AbstractType& declared_type = AbstractType::Handle(type()); |
| 5928 cls = declared_type.type_class(); |
| 5929 jsobj.AddProperty("declared_type", cls); |
| 5930 jsobj.AddProperty("static", is_static()); |
| 5931 jsobj.AddProperty("final", is_final()); |
| 5932 jsobj.AddProperty("const", is_const()); |
5921 if (ref) { | 5933 if (ref) { |
5922 return; | 5934 return; |
5923 } | 5935 } |
5924 Class& cls = Class::Handle(owner()); | |
5925 jsobj.AddProperty("type", "Field"); | |
5926 jsobj.AddProperty("id", id); | |
5927 jsobj.AddProperty("name", internal_field_name); | |
5928 jsobj.AddProperty("user_name", field_name); | |
5929 jsobj.AddProperty("class", cls); | |
5930 jsobj.AddProperty("static", is_static()); | |
5931 jsobj.AddProperty("final", is_final()); | |
5932 jsobj.AddProperty("const", is_const()); | |
5933 jsobj.AddProperty("guard_nullable", is_nullable()); | 5936 jsobj.AddProperty("guard_nullable", is_nullable()); |
5934 if (guarded_cid() == kIllegalCid) { | 5937 if (guarded_cid() == kIllegalCid) { |
5935 jsobj.AddProperty("guard_class", "unknown"); | 5938 jsobj.AddProperty("guard_class", "unknown"); |
5936 } else if (guarded_cid() == kDynamicCid) { | 5939 } else if (guarded_cid() == kDynamicCid) { |
5937 jsobj.AddProperty("guard_class", "dynamic"); | 5940 jsobj.AddProperty("guard_class", "dynamic"); |
5938 } else { | 5941 } else { |
5939 ClassTable* table = Isolate::Current()->class_table(); | 5942 ClassTable* table = Isolate::Current()->class_table(); |
5940 ASSERT(table->IsValidIndex(guarded_cid())); | 5943 ASSERT(table->IsValidIndex(guarded_cid())); |
5941 cls ^= table->At(guarded_cid()); | 5944 cls ^= table->At(guarded_cid()); |
5942 jsobj.AddProperty("guard_class", cls); | 5945 jsobj.AddProperty("guard_class", cls); |
(...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8116 | 8119 |
8117 void Library::PrintToJSONStream(JSONStream* stream, bool ref) const { | 8120 void Library::PrintToJSONStream(JSONStream* stream, bool ref) const { |
8118 const char* library_name = String::Handle(name()).ToCString(); | 8121 const char* library_name = String::Handle(name()).ToCString(); |
8119 const char* library_url = String::Handle(url()).ToCString(); | 8122 const char* library_url = String::Handle(url()).ToCString(); |
8120 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 8123 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
8121 intptr_t id = ring->GetIdForObject(raw()); | 8124 intptr_t id = ring->GetIdForObject(raw()); |
8122 JSONObject jsobj(stream); | 8125 JSONObject jsobj(stream); |
8123 jsobj.AddProperty("type", JSONType(ref)); | 8126 jsobj.AddProperty("type", JSONType(ref)); |
8124 jsobj.AddProperty("id", id); | 8127 jsobj.AddProperty("id", id); |
8125 jsobj.AddProperty("name", library_name); | 8128 jsobj.AddProperty("name", library_name); |
| 8129 jsobj.AddProperty("url", library_url); |
8126 if (ref) return; | 8130 if (ref) return; |
8127 jsobj.AddProperty("url", library_url); | |
8128 { | 8131 { |
8129 JSONArray jsarr(&jsobj, "classes"); | 8132 JSONArray jsarr(&jsobj, "classes"); |
8130 ClassDictionaryIterator class_iter(*this); | 8133 ClassDictionaryIterator class_iter(*this); |
8131 Class& klass = Class::Handle(); | 8134 Class& klass = Class::Handle(); |
8132 while (class_iter.HasNext()) { | 8135 while (class_iter.HasNext()) { |
8133 klass = class_iter.GetNextClass(); | 8136 klass = class_iter.GetNextClass(); |
8134 jsarr.AddValue(klass); | 8137 if (!klass.IsCanonicalSignatureClass() && |
| 8138 !klass.IsAnonymousMixinApplication()) { |
| 8139 jsarr.AddValue(klass); |
| 8140 } |
8135 } | 8141 } |
8136 } | 8142 } |
8137 { | 8143 { |
8138 JSONArray jsarr(&jsobj, "libraries"); | 8144 JSONArray jsarr(&jsobj, "libraries"); |
8139 Library& lib = Library::Handle(); | 8145 Library& lib = Library::Handle(); |
8140 for (intptr_t i = 0; i < num_imports(); i++) { | 8146 for (intptr_t i = 0; i < num_imports(); i++) { |
8141 lib = ImportLibraryAt(i); | 8147 lib = ImportLibraryAt(i); |
8142 jsarr.AddValue(lib); | 8148 jsarr.AddValue(lib); |
8143 } | 8149 } |
8144 } | 8150 } |
| 8151 { |
| 8152 JSONArray jsarr(&jsobj, "variables"); |
| 8153 DictionaryIterator entries(*this); |
| 8154 Object& entry = Object::Handle(); |
| 8155 while (entries.HasNext()) { |
| 8156 entry = entries.GetNext(); |
| 8157 if (entry.IsField()) { |
| 8158 jsarr.AddValue(entry); |
| 8159 } |
| 8160 } |
| 8161 } |
| 8162 { |
| 8163 JSONArray jsarr(&jsobj, "functions"); |
| 8164 DictionaryIterator entries(*this); |
| 8165 Object& entry = Object::Handle(); |
| 8166 while (entries.HasNext()) { |
| 8167 entry = entries.GetNext(); |
| 8168 if (entry.IsFunction()) { |
| 8169 const Function& func = Function::Cast(entry); |
| 8170 if (func.kind() == RawFunction::kRegularFunction || |
| 8171 func.kind() == RawFunction::kGetterFunction || |
| 8172 func.kind() == RawFunction::kSetterFunction) { |
| 8173 jsarr.AddValue(func); |
| 8174 } |
| 8175 } |
| 8176 } |
| 8177 } |
8145 } | 8178 } |
8146 | 8179 |
8147 | 8180 |
8148 RawLibrary* LibraryPrefix::GetLibrary(int index) const { | 8181 RawLibrary* LibraryPrefix::GetLibrary(int index) const { |
8149 if ((index >= 0) || (index < num_imports())) { | 8182 if ((index >= 0) || (index < num_imports())) { |
8150 const Array& imports = Array::Handle(this->imports()); | 8183 const Array& imports = Array::Handle(this->imports()); |
8151 Namespace& import = Namespace::Handle(); | 8184 Namespace& import = Namespace::Handle(); |
8152 import ^= imports.At(index); | 8185 import ^= imports.At(index); |
8153 return import.library(); | 8186 return import.library(); |
8154 } | 8187 } |
(...skipping 3180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11335 // Calculate the size of the string. | 11368 // Calculate the size of the string. |
11336 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; | 11369 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; |
11337 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 11370 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
11338 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); | 11371 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); |
11339 return chars; | 11372 return chars; |
11340 } | 11373 } |
11341 } | 11374 } |
11342 | 11375 |
11343 | 11376 |
11344 void Instance::PrintToJSONStream(JSONStream* stream, bool ref) const { | 11377 void Instance::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 11378 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 11379 intptr_t id = ring->GetIdForObject(raw()); |
| 11380 |
11345 JSONObject jsobj(stream); | 11381 JSONObject jsobj(stream); |
| 11382 jsobj.AddProperty("type", JSONType(ref)); |
| 11383 jsobj.AddProperty("id", id); |
| 11384 |
| 11385 // Set the "preview" property for this instance. |
| 11386 if (IsNull()) { |
| 11387 jsobj.AddProperty("preview", "null"); |
| 11388 } else if (raw() == Object::sentinel().raw() || |
| 11389 raw() == Object::transition_sentinel().raw()) { |
| 11390 jsobj.AddProperty("preview", "<uninitialized>"); |
| 11391 } else { |
| 11392 // TODO(turnidge): Handle special characters? Truncate? |
| 11393 jsobj.AddProperty("preview", ToCString()); |
| 11394 } |
11346 } | 11395 } |
11347 | 11396 |
11348 | 11397 |
11349 bool AbstractType::IsResolved() const { | 11398 bool AbstractType::IsResolved() const { |
11350 // AbstractType is an abstract class. | 11399 // AbstractType is an abstract class. |
11351 UNREACHABLE(); | 11400 UNREACHABLE(); |
11352 return false; | 11401 return false; |
11353 } | 11402 } |
11354 | 11403 |
11355 | 11404 |
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12670 | 12719 |
12671 | 12720 |
12672 const char* Number::ToCString() const { | 12721 const char* Number::ToCString() const { |
12673 // Number is an interface. No instances of Number should exist. | 12722 // Number is an interface. No instances of Number should exist. |
12674 UNREACHABLE(); | 12723 UNREACHABLE(); |
12675 return "Number"; | 12724 return "Number"; |
12676 } | 12725 } |
12677 | 12726 |
12678 | 12727 |
12679 void Number::PrintToJSONStream(JSONStream* stream, bool ref) const { | 12728 void Number::PrintToJSONStream(JSONStream* stream, bool ref) const { |
12680 JSONObject jsobj(stream); | 12729 Instance::PrintToJSONStream(stream, ref); |
12681 } | 12730 } |
12682 | 12731 |
12683 | 12732 |
12684 const char* Integer::ToCString() const { | 12733 const char* Integer::ToCString() const { |
12685 // Integer is an interface. No instances of Integer should exist. | 12734 // Integer is an interface. No instances of Integer should exist. |
12686 UNREACHABLE(); | 12735 UNREACHABLE(); |
12687 return "Integer"; | 12736 return "Integer"; |
12688 } | 12737 } |
12689 | 12738 |
12690 | 12739 |
12691 void Integer::PrintToJSONStream(JSONStream* stream, bool ref) const { | 12740 void Integer::PrintToJSONStream(JSONStream* stream, bool ref) const { |
12692 JSONObject jsobj(stream); | 12741 Number::PrintToJSONStream(stream, ref); |
12693 } | 12742 } |
12694 | 12743 |
12695 | 12744 |
12696 // Throw JavascriptIntegerOverflow exception. | 12745 // Throw JavascriptIntegerOverflow exception. |
12697 static void ThrowJavascriptIntegerOverflow(const Integer& i) { | 12746 static void ThrowJavascriptIntegerOverflow(const Integer& i) { |
12698 const Array& exc_args = Array::Handle(Array::New(1)); | 12747 const Array& exc_args = Array::Handle(Array::New(1)); |
12699 const String& i_str = String::Handle(String::New(i.ToCString())); | 12748 const String& i_str = String::Handle(String::New(i.ToCString())); |
12700 exc_args.SetAt(0, i_str); | 12749 exc_args.SetAt(0, i_str); |
12701 Exceptions::ThrowByType(Exceptions::kJavascriptIntegerOverflowError, | 12750 Exceptions::ThrowByType(Exceptions::kJavascriptIntegerOverflowError, |
12702 exc_args); | 12751 exc_args); |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13100 const char* kFormat = "%ld"; | 13149 const char* kFormat = "%ld"; |
13101 // Calculate the size of the string. | 13150 // Calculate the size of the string. |
13102 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1; | 13151 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1; |
13103 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 13152 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
13104 OS::SNPrint(chars, len, kFormat, Value()); | 13153 OS::SNPrint(chars, len, kFormat, Value()); |
13105 return chars; | 13154 return chars; |
13106 } | 13155 } |
13107 | 13156 |
13108 | 13157 |
13109 void Smi::PrintToJSONStream(JSONStream* stream, bool ref) const { | 13158 void Smi::PrintToJSONStream(JSONStream* stream, bool ref) const { |
13110 JSONObject jsobj(stream); | 13159 Number::PrintToJSONStream(stream, ref); |
13111 } | 13160 } |
13112 | 13161 |
13113 | 13162 |
13114 RawClass* Smi::Class() { | 13163 RawClass* Smi::Class() { |
13115 return Isolate::Current()->object_store()->smi_class(); | 13164 return Isolate::Current()->object_store()->smi_class(); |
13116 } | 13165 } |
13117 | 13166 |
13118 | 13167 |
13119 void Mint::set_value(int64_t value) const { | 13168 void Mint::set_value(int64_t value) const { |
13120 raw_ptr()->value_ = value; | 13169 raw_ptr()->value_ = value; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13219 const char* kFormat = "%lld"; | 13268 const char* kFormat = "%lld"; |
13220 // Calculate the size of the string. | 13269 // Calculate the size of the string. |
13221 intptr_t len = OS::SNPrint(NULL, 0, kFormat, value()) + 1; | 13270 intptr_t len = OS::SNPrint(NULL, 0, kFormat, value()) + 1; |
13222 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 13271 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
13223 OS::SNPrint(chars, len, kFormat, value()); | 13272 OS::SNPrint(chars, len, kFormat, value()); |
13224 return chars; | 13273 return chars; |
13225 } | 13274 } |
13226 | 13275 |
13227 | 13276 |
13228 void Mint::PrintToJSONStream(JSONStream* stream, bool ref) const { | 13277 void Mint::PrintToJSONStream(JSONStream* stream, bool ref) const { |
13229 JSONObject jsobj(stream); | 13278 Number::PrintToJSONStream(stream, ref); |
13230 } | 13279 } |
13231 | 13280 |
13232 | 13281 |
13233 void Double::set_value(double value) const { | 13282 void Double::set_value(double value) const { |
13234 raw_ptr()->value_ = value; | 13283 raw_ptr()->value_ = value; |
13235 } | 13284 } |
13236 | 13285 |
13237 | 13286 |
13238 bool Double::EqualsToDouble(double value) const { | 13287 bool Double::EqualsToDouble(double value) const { |
13239 intptr_t value_offset = Double::value_offset(); | 13288 intptr_t value_offset = Double::value_offset(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13325 } | 13374 } |
13326 const int kBufferSize = 128; | 13375 const int kBufferSize = 128; |
13327 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize); | 13376 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize); |
13328 buffer[kBufferSize - 1] = '\0'; | 13377 buffer[kBufferSize - 1] = '\0'; |
13329 DoubleToCString(value(), buffer, kBufferSize); | 13378 DoubleToCString(value(), buffer, kBufferSize); |
13330 return buffer; | 13379 return buffer; |
13331 } | 13380 } |
13332 | 13381 |
13333 | 13382 |
13334 void Double::PrintToJSONStream(JSONStream* stream, bool ref) const { | 13383 void Double::PrintToJSONStream(JSONStream* stream, bool ref) const { |
13335 JSONObject jsobj(stream); | 13384 Number::PrintToJSONStream(stream, ref); |
13336 } | 13385 } |
13337 | 13386 |
13338 | 13387 |
13339 RawBigint* Integer::AsBigint() const { | 13388 RawBigint* Integer::AsBigint() const { |
13340 ASSERT(!IsNull()); | 13389 ASSERT(!IsNull()); |
13341 if (IsSmi()) { | 13390 if (IsSmi()) { |
13342 Smi& smi = Smi::Handle(); | 13391 Smi& smi = Smi::Handle(); |
13343 smi ^= raw(); | 13392 smi ^= raw(); |
13344 return BigintOperations::NewFromSmi(smi); | 13393 return BigintOperations::NewFromSmi(smi); |
13345 } else if (IsMint()) { | 13394 } else if (IsMint()) { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13496 return zone->AllocUnsafe(size); | 13545 return zone->AllocUnsafe(size); |
13497 } | 13546 } |
13498 | 13547 |
13499 | 13548 |
13500 const char* Bigint::ToCString() const { | 13549 const char* Bigint::ToCString() const { |
13501 return BigintOperations::ToDecimalCString(*this, &BigintAllocator); | 13550 return BigintOperations::ToDecimalCString(*this, &BigintAllocator); |
13502 } | 13551 } |
13503 | 13552 |
13504 | 13553 |
13505 void Bigint::PrintToJSONStream(JSONStream* stream, bool ref) const { | 13554 void Bigint::PrintToJSONStream(JSONStream* stream, bool ref) const { |
13506 JSONObject jsobj(stream); | 13555 Number::PrintToJSONStream(stream, ref); |
13507 } | 13556 } |
13508 | 13557 |
13509 | 13558 |
13510 // Synchronize with implementation in compiler (intrinsifier). | 13559 // Synchronize with implementation in compiler (intrinsifier). |
13511 class StringHasher : ValueObject { | 13560 class StringHasher : ValueObject { |
13512 public: | 13561 public: |
13513 StringHasher() : hash_(0) {} | 13562 StringHasher() : hash_(0) {} |
13514 void Add(int32_t ch) { | 13563 void Add(int32_t ch) { |
13515 hash_ += ch; | 13564 hash_ += ch; |
13516 hash_ += hash_ << 10; | 13565 hash_ += hash_ << 10; |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14119 const intptr_t len = Utf8::Length(*this); | 14168 const intptr_t len = Utf8::Length(*this); |
14120 Zone* zone = Isolate::Current()->current_zone(); | 14169 Zone* zone = Isolate::Current()->current_zone(); |
14121 uint8_t* result = zone->Alloc<uint8_t>(len + 1); | 14170 uint8_t* result = zone->Alloc<uint8_t>(len + 1); |
14122 ToUTF8(result, len); | 14171 ToUTF8(result, len); |
14123 result[len] = 0; | 14172 result[len] = 0; |
14124 return reinterpret_cast<const char*>(result); | 14173 return reinterpret_cast<const char*>(result); |
14125 } | 14174 } |
14126 | 14175 |
14127 | 14176 |
14128 void String::PrintToJSONStream(JSONStream* stream, bool ref) const { | 14177 void String::PrintToJSONStream(JSONStream* stream, bool ref) const { |
14129 JSONObject jsobj(stream); | 14178 Instance::PrintToJSONStream(stream, ref); |
14130 } | 14179 } |
14131 | 14180 |
14132 | 14181 |
14133 void String::ToUTF8(uint8_t* utf8_array, intptr_t array_len) const { | 14182 void String::ToUTF8(uint8_t* utf8_array, intptr_t array_len) const { |
14134 ASSERT(array_len >= Utf8::Length(*this)); | 14183 ASSERT(array_len >= Utf8::Length(*this)); |
14135 Utf8::Encode(*this, reinterpret_cast<char*>(utf8_array), array_len); | 14184 Utf8::Encode(*this, reinterpret_cast<char*>(utf8_array), array_len); |
14136 } | 14185 } |
14137 | 14186 |
14138 | 14187 |
14139 static FinalizablePersistentHandle* AddFinalizer( | 14188 static FinalizablePersistentHandle* AddFinalizer( |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14877 return result.raw(); | 14926 return result.raw(); |
14878 } | 14927 } |
14879 | 14928 |
14880 | 14929 |
14881 const char* Bool::ToCString() const { | 14930 const char* Bool::ToCString() const { |
14882 return value() ? "true" : "false"; | 14931 return value() ? "true" : "false"; |
14883 } | 14932 } |
14884 | 14933 |
14885 | 14934 |
14886 void Bool::PrintToJSONStream(JSONStream* stream, bool ref) const { | 14935 void Bool::PrintToJSONStream(JSONStream* stream, bool ref) const { |
14887 JSONObject jsobj(stream); | 14936 Instance::PrintToJSONStream(stream, ref); |
14888 } | 14937 } |
14889 | 14938 |
14890 | 14939 |
14891 bool Array::Equals(const Instance& other) const { | 14940 bool Array::Equals(const Instance& other) const { |
14892 if (this->raw() == other.raw()) { | 14941 if (this->raw() == other.raw()) { |
14893 // Both handles point to the same raw instance. | 14942 // Both handles point to the same raw instance. |
14894 return true; | 14943 return true; |
14895 } | 14944 } |
14896 | 14945 |
14897 // An Array may be compared to an ImmutableArray. | 14946 // An Array may be compared to an ImmutableArray. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14963 const char* format = IsImmutable() ? | 15012 const char* format = IsImmutable() ? |
14964 "_ImmutableList len:%" Pd : "_List len:%" Pd; | 15013 "_ImmutableList len:%" Pd : "_List len:%" Pd; |
14965 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; | 15014 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; |
14966 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15015 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
14967 OS::SNPrint(chars, len, format, Length()); | 15016 OS::SNPrint(chars, len, format, Length()); |
14968 return chars; | 15017 return chars; |
14969 } | 15018 } |
14970 | 15019 |
14971 | 15020 |
14972 void Array::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15021 void Array::PrintToJSONStream(JSONStream* stream, bool ref) const { |
14973 JSONObject jsobj(stream); | 15022 Instance::PrintToJSONStream(stream, ref); |
14974 } | 15023 } |
14975 | 15024 |
14976 | 15025 |
14977 RawArray* Array::Grow(const Array& source, int new_length, Heap::Space space) { | 15026 RawArray* Array::Grow(const Array& source, int new_length, Heap::Space space) { |
14978 const Array& result = Array::Handle(Array::New(new_length, space)); | 15027 const Array& result = Array::Handle(Array::New(new_length, space)); |
14979 intptr_t len = 0; | 15028 intptr_t len = 0; |
14980 if (!source.IsNull()) { | 15029 if (!source.IsNull()) { |
14981 len = source.Length(); | 15030 len = source.Length(); |
14982 result.SetTypeArguments( | 15031 result.SetTypeArguments( |
14983 AbstractTypeArguments::Handle(source.GetTypeArguments())); | 15032 AbstractTypeArguments::Handle(source.GetTypeArguments())); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15176 const char* format = "_GrowableList len:%" Pd ""; | 15225 const char* format = "_GrowableList len:%" Pd ""; |
15177 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; | 15226 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; |
15178 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15227 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
15179 OS::SNPrint(chars, len, format, Length()); | 15228 OS::SNPrint(chars, len, format, Length()); |
15180 return chars; | 15229 return chars; |
15181 } | 15230 } |
15182 | 15231 |
15183 | 15232 |
15184 void GrowableObjectArray::PrintToJSONStream(JSONStream* stream, | 15233 void GrowableObjectArray::PrintToJSONStream(JSONStream* stream, |
15185 bool ref) const { | 15234 bool ref) const { |
15186 JSONObject jsobj(stream); | 15235 Instance::PrintToJSONStream(stream, ref); |
15187 } | 15236 } |
15188 | 15237 |
15189 | 15238 |
15190 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, | 15239 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, |
15191 Heap::Space space) { | 15240 Heap::Space space) { |
15192 ASSERT(Isolate::Current()->object_store()->float32x4_class() != | 15241 ASSERT(Isolate::Current()->object_store()->float32x4_class() != |
15193 Class::null()); | 15242 Class::null()); |
15194 Float32x4& result = Float32x4::Handle(); | 15243 Float32x4& result = Float32x4::Handle(); |
15195 { | 15244 { |
15196 RawObject* raw = Object::Allocate(Float32x4::kClassId, | 15245 RawObject* raw = Object::Allocate(Float32x4::kClassId, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15281 float _w = w(); | 15330 float _w = w(); |
15282 // Calculate the size of the string. | 15331 // Calculate the size of the string. |
15283 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; | 15332 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; |
15284 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15333 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
15285 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); | 15334 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); |
15286 return chars; | 15335 return chars; |
15287 } | 15336 } |
15288 | 15337 |
15289 | 15338 |
15290 void Float32x4::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15339 void Float32x4::PrintToJSONStream(JSONStream* stream, bool ref) const { |
15291 JSONObject jsobj(stream); | 15340 Instance::PrintToJSONStream(stream, ref); |
15292 } | 15341 } |
15293 | 15342 |
15294 | 15343 |
15295 RawInt32x4* Int32x4::New(int32_t v0, int32_t v1, int32_t v2, int32_t v3, | 15344 RawInt32x4* Int32x4::New(int32_t v0, int32_t v1, int32_t v2, int32_t v3, |
15296 Heap::Space space) { | 15345 Heap::Space space) { |
15297 ASSERT(Isolate::Current()->object_store()->int32x4_class() != | 15346 ASSERT(Isolate::Current()->object_store()->int32x4_class() != |
15298 Class::null()); | 15347 Class::null()); |
15299 Int32x4& result = Int32x4::Handle(); | 15348 Int32x4& result = Int32x4::Handle(); |
15300 { | 15349 { |
15301 RawObject* raw = Object::Allocate(Int32x4::kClassId, | 15350 RawObject* raw = Object::Allocate(Int32x4::kClassId, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15386 int32_t _w = w(); | 15435 int32_t _w = w(); |
15387 // Calculate the size of the string. | 15436 // Calculate the size of the string. |
15388 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; | 15437 intptr_t len = OS::SNPrint(NULL, 0, kFormat, _x, _y, _z, _w) + 1; |
15389 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15438 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
15390 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); | 15439 OS::SNPrint(chars, len, kFormat, _x, _y, _z, _w); |
15391 return chars; | 15440 return chars; |
15392 } | 15441 } |
15393 | 15442 |
15394 | 15443 |
15395 void Int32x4::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15444 void Int32x4::PrintToJSONStream(JSONStream* stream, bool ref) const { |
15396 JSONObject jsobj(stream); | 15445 Instance::PrintToJSONStream(stream, ref); |
15397 } | 15446 } |
15398 | 15447 |
15399 | 15448 |
15400 const intptr_t TypedData::element_size[] = { | 15449 const intptr_t TypedData::element_size[] = { |
15401 1, // kTypedDataInt8ArrayCid. | 15450 1, // kTypedDataInt8ArrayCid. |
15402 1, // kTypedDataUint8ArrayCid. | 15451 1, // kTypedDataUint8ArrayCid. |
15403 1, // kTypedDataUint8ClampedArrayCid. | 15452 1, // kTypedDataUint8ClampedArrayCid. |
15404 2, // kTypedDataInt16ArrayCid. | 15453 2, // kTypedDataInt16ArrayCid. |
15405 2, // kTypedDataUint16ArrayCid. | 15454 2, // kTypedDataUint16ArrayCid. |
15406 4, // kTypedDataInt32ArrayCid. | 15455 4, // kTypedDataInt32ArrayCid. |
(...skipping 29 matching lines...) Expand all Loading... |
15436 return result.raw(); | 15485 return result.raw(); |
15437 } | 15486 } |
15438 | 15487 |
15439 | 15488 |
15440 const char* TypedData::ToCString() const { | 15489 const char* TypedData::ToCString() const { |
15441 return "TypedData"; | 15490 return "TypedData"; |
15442 } | 15491 } |
15443 | 15492 |
15444 | 15493 |
15445 void TypedData::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15494 void TypedData::PrintToJSONStream(JSONStream* stream, bool ref) const { |
15446 JSONObject jsobj(stream); | 15495 Instance::PrintToJSONStream(stream, ref); |
15447 } | 15496 } |
15448 | 15497 |
15449 | 15498 |
15450 FinalizablePersistentHandle* ExternalTypedData::AddFinalizer( | 15499 FinalizablePersistentHandle* ExternalTypedData::AddFinalizer( |
15451 void* peer, Dart_WeakPersistentHandleFinalizer callback) const { | 15500 void* peer, Dart_WeakPersistentHandleFinalizer callback) const { |
15452 SetPeer(peer); | 15501 SetPeer(peer); |
15453 return dart::AddFinalizer(*this, peer, callback); | 15502 return dart::AddFinalizer(*this, peer, callback); |
15454 } | 15503 } |
15455 | 15504 |
15456 | 15505 |
(...skipping 15 matching lines...) Expand all Loading... |
15472 } | 15521 } |
15473 | 15522 |
15474 | 15523 |
15475 const char* ExternalTypedData::ToCString() const { | 15524 const char* ExternalTypedData::ToCString() const { |
15476 return "ExternalTypedData"; | 15525 return "ExternalTypedData"; |
15477 } | 15526 } |
15478 | 15527 |
15479 | 15528 |
15480 void ExternalTypedData::PrintToJSONStream(JSONStream* stream, | 15529 void ExternalTypedData::PrintToJSONStream(JSONStream* stream, |
15481 bool ref) const { | 15530 bool ref) const { |
15482 JSONObject jsobj(stream); | 15531 Instance::PrintToJSONStream(stream, ref); |
15483 } | 15532 } |
15484 | 15533 |
15485 | 15534 |
15486 | 15535 |
15487 const char* Closure::ToCString(const Instance& closure) { | 15536 const char* Closure::ToCString(const Instance& closure) { |
15488 const Function& fun = Function::Handle(Closure::function(closure)); | 15537 const Function& fun = Function::Handle(Closure::function(closure)); |
15489 const bool is_implicit_closure = fun.IsImplicitClosureFunction(); | 15538 const bool is_implicit_closure = fun.IsImplicitClosureFunction(); |
15490 const char* fun_sig = String::Handle(fun.UserVisibleSignature()).ToCString(); | 15539 const char* fun_sig = String::Handle(fun.UserVisibleSignature()).ToCString(); |
15491 const char* from = is_implicit_closure ? " from " : ""; | 15540 const char* from = is_implicit_closure ? " from " : ""; |
15492 const char* fun_desc = is_implicit_closure ? fun.ToCString() : ""; | 15541 const char* fun_desc = is_implicit_closure ? fun.ToCString() : ""; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15659 } | 15708 } |
15660 | 15709 |
15661 | 15710 |
15662 const char* Stacktrace::ToCString() const { | 15711 const char* Stacktrace::ToCString() const { |
15663 const String& trace = String::Handle(FullStacktrace()); | 15712 const String& trace = String::Handle(FullStacktrace()); |
15664 return trace.ToCString(); | 15713 return trace.ToCString(); |
15665 } | 15714 } |
15666 | 15715 |
15667 | 15716 |
15668 void Stacktrace::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15717 void Stacktrace::PrintToJSONStream(JSONStream* stream, bool ref) const { |
15669 JSONObject jsobj(stream); | 15718 Instance::PrintToJSONStream(stream, ref); |
15670 } | 15719 } |
15671 | 15720 |
15672 | 15721 |
15673 static intptr_t PrintOneStacktrace(Isolate* isolate, | 15722 static intptr_t PrintOneStacktrace(Isolate* isolate, |
15674 GrowableArray<char*>* frame_strings, | 15723 GrowableArray<char*>* frame_strings, |
15675 uword pc, | 15724 uword pc, |
15676 const Function& function, | 15725 const Function& function, |
15677 const Code& code, | 15726 const Code& code, |
15678 intptr_t frame_index) { | 15727 intptr_t frame_index) { |
15679 const char* kFormatWithCol = "#%-6d %s (%s:%d:%d)\n"; | 15728 const char* kFormatWithCol = "#%-6d %s (%s:%d:%d)\n"; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15869 const String& str = String::Handle(pattern()); | 15918 const String& str = String::Handle(pattern()); |
15870 const char* format = "JSRegExp: pattern=%s flags=%s"; | 15919 const char* format = "JSRegExp: pattern=%s flags=%s"; |
15871 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 15920 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
15872 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); | 15921 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); |
15873 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 15922 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
15874 return chars; | 15923 return chars; |
15875 } | 15924 } |
15876 | 15925 |
15877 | 15926 |
15878 void JSRegExp::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15927 void JSRegExp::PrintToJSONStream(JSONStream* stream, bool ref) const { |
15879 JSONObject jsobj(stream); | 15928 Instance::PrintToJSONStream(stream, ref); |
15880 } | 15929 } |
15881 | 15930 |
15882 | 15931 |
15883 RawWeakProperty* WeakProperty::New(Heap::Space space) { | 15932 RawWeakProperty* WeakProperty::New(Heap::Space space) { |
15884 ASSERT(Isolate::Current()->object_store()->weak_property_class() | 15933 ASSERT(Isolate::Current()->object_store()->weak_property_class() |
15885 != Class::null()); | 15934 != Class::null()); |
15886 RawObject* raw = Object::Allocate(WeakProperty::kClassId, | 15935 RawObject* raw = Object::Allocate(WeakProperty::kClassId, |
15887 WeakProperty::InstanceSize(), | 15936 WeakProperty::InstanceSize(), |
15888 space); | 15937 space); |
15889 return reinterpret_cast<RawWeakProperty*>(raw); | 15938 return reinterpret_cast<RawWeakProperty*>(raw); |
15890 } | 15939 } |
15891 | 15940 |
15892 | 15941 |
15893 const char* WeakProperty::ToCString() const { | 15942 const char* WeakProperty::ToCString() const { |
15894 return "_WeakProperty"; | 15943 return "_WeakProperty"; |
15895 } | 15944 } |
15896 | 15945 |
15897 | 15946 |
15898 void WeakProperty::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15947 void WeakProperty::PrintToJSONStream(JSONStream* stream, bool ref) const { |
15899 JSONObject jsobj(stream); | 15948 Instance::PrintToJSONStream(stream, ref); |
15900 } | 15949 } |
15901 | 15950 |
15902 RawAbstractType* MirrorReference::GetAbstractTypeReferent() const { | 15951 RawAbstractType* MirrorReference::GetAbstractTypeReferent() const { |
15903 ASSERT(Object::Handle(referent()).IsAbstractType()); | 15952 ASSERT(Object::Handle(referent()).IsAbstractType()); |
15904 return AbstractType::Cast(Object::Handle(referent())).raw(); | 15953 return AbstractType::Cast(Object::Handle(referent())).raw(); |
15905 } | 15954 } |
15906 | 15955 |
15907 | 15956 |
15908 RawClass* MirrorReference::GetClassReferent() const { | 15957 RawClass* MirrorReference::GetClassReferent() const { |
15909 ASSERT(Object::Handle(referent()).IsClass()); | 15958 ASSERT(Object::Handle(referent()).IsClass()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15951 return result.raw(); | 16000 return result.raw(); |
15952 } | 16001 } |
15953 | 16002 |
15954 | 16003 |
15955 const char* MirrorReference::ToCString() const { | 16004 const char* MirrorReference::ToCString() const { |
15956 return "_MirrorReference"; | 16005 return "_MirrorReference"; |
15957 } | 16006 } |
15958 | 16007 |
15959 | 16008 |
15960 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 16009 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
15961 JSONObject jsobj(stream); | 16010 Instance::PrintToJSONStream(stream, ref); |
15962 } | 16011 } |
15963 | 16012 |
15964 | 16013 |
15965 } // namespace dart | 16014 } // namespace dart |
OLD | NEW |