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 15940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15951 | 15951 |
15952 RawDouble* Double::NewCanonical(const String& str) { | 15952 RawDouble* Double::NewCanonical(const String& str) { |
15953 double double_value; | 15953 double double_value; |
15954 if (!CStringToDouble(str.ToCString(), str.Length(), &double_value)) { | 15954 if (!CStringToDouble(str.ToCString(), str.Length(), &double_value)) { |
15955 return Double::Handle().raw(); | 15955 return Double::Handle().raw(); |
15956 } | 15956 } |
15957 return NewCanonical(double_value); | 15957 return NewCanonical(double_value); |
15958 } | 15958 } |
15959 | 15959 |
15960 | 15960 |
| 15961 RawString* Number::ToString(Heap::Space space) const { |
| 15962 // Refactoring can avoid Zone::Alloc and strlen, but gains are insignificant. |
| 15963 const char* cstr = ToCString(); |
| 15964 intptr_t len = strlen(cstr); |
| 15965 // Resulting string is ASCII ... |
| 15966 #ifdef DEBUG |
| 15967 for (intptr_t i = 0; i < len; ++i) { |
| 15968 ASSERT(static_cast<uint8_t>(cstr[i]) < 128); |
| 15969 } |
| 15970 #endif // DEBUG |
| 15971 // ... which is a subset of Latin-1. |
| 15972 return String::FromLatin1(reinterpret_cast<const uint8_t*>(cstr), len, space); |
| 15973 } |
| 15974 |
| 15975 |
15961 const char* Double::ToCString() const { | 15976 const char* Double::ToCString() const { |
15962 if (isnan(value())) { | 15977 if (isnan(value())) { |
15963 return "NaN"; | 15978 return "NaN"; |
15964 } | 15979 } |
15965 if (isinf(value())) { | 15980 if (isinf(value())) { |
15966 return value() < 0 ? "-Infinity" : "Infinity"; | 15981 return value() < 0 ? "-Infinity" : "Infinity"; |
15967 } | 15982 } |
15968 const int kBufferSize = 128; | 15983 const int kBufferSize = 128; |
15969 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize); | 15984 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize); |
15970 buffer[kBufferSize - 1] = '\0'; | 15985 buffer[kBufferSize - 1] = '\0'; |
(...skipping 3512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19483 return tag_label.ToCString(); | 19498 return tag_label.ToCString(); |
19484 } | 19499 } |
19485 | 19500 |
19486 | 19501 |
19487 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19502 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
19488 Instance::PrintJSONImpl(stream, ref); | 19503 Instance::PrintJSONImpl(stream, ref); |
19489 } | 19504 } |
19490 | 19505 |
19491 | 19506 |
19492 } // namespace dart | 19507 } // namespace dart |
OLD | NEW |