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 16909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16920 // TODO(cshapiro): create a fast-path for OneByteString instances. | 16920 // TODO(cshapiro): create a fast-path for OneByteString instances. |
16921 return Transform(CaseMapping::ToLower, str, space); | 16921 return Transform(CaseMapping::ToLower, str, space); |
16922 } | 16922 } |
16923 | 16923 |
16924 bool String::ParseDouble(const String& str, | 16924 bool String::ParseDouble(const String& str, |
16925 intptr_t start, intptr_t end, | 16925 intptr_t start, intptr_t end, |
16926 double* result) { | 16926 double* result) { |
16927 ASSERT(0 <= start); | 16927 ASSERT(0 <= start); |
16928 ASSERT(start <= end); | 16928 ASSERT(start <= end); |
16929 ASSERT(end <= str.Length()); | 16929 ASSERT(end <= str.Length()); |
16930 int length = end - start; | 16930 intptr_t length = end - start; |
16931 NoGCScope no_gc; | 16931 NoGCScope no_gc; |
16932 const uint8_t* startChar; | 16932 const uint8_t* startChar; |
16933 if (str.IsOneByteString()) { | 16933 if (str.IsOneByteString()) { |
16934 startChar = OneByteString::CharAddr(str, start); | 16934 startChar = OneByteString::CharAddr(str, start); |
16935 } else if (str.IsExternalOneByteString()) { | 16935 } else if (str.IsExternalOneByteString()) { |
16936 startChar = ExternalOneByteString::CharAddr(str, start); | 16936 startChar = ExternalOneByteString::CharAddr(str, start); |
16937 } else { | 16937 } else { |
16938 uint8_t* chars = Isolate::Current()->current_zone()->Alloc<uint8_t>(length); | 16938 uint8_t* chars = Isolate::Current()->current_zone()->Alloc<uint8_t>(length); |
16939 for (int i = 0; i < length; i++) { | 16939 const Scanner::CharAtFunc char_at = str.CharAtFunc(); |
16940 int ch = str.CharAt(start + i); | 16940 for (intptr_t i = 0; i < length; i++) { |
| 16941 int32_t ch = char_at(str, start + i); |
16941 if (ch < 128) { | 16942 if (ch < 128) { |
16942 chars[i] = ch; | 16943 chars[i] = ch; |
16943 } else { | 16944 } else { |
16944 return false; // Not ASCII, so definitely not valid double numeral. | 16945 return false; // Not ASCII, so definitely not valid double numeral. |
16945 } | 16946 } |
16946 } | 16947 } |
16947 startChar = chars; | 16948 startChar = chars; |
16948 } | 16949 } |
16949 return CStringToDouble(reinterpret_cast<const char*>(startChar), | 16950 return CStringToDouble(reinterpret_cast<const char*>(startChar), |
16950 length, result); | 16951 length, result); |
(...skipping 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19035 return tag_label.ToCString(); | 19036 return tag_label.ToCString(); |
19036 } | 19037 } |
19037 | 19038 |
19038 | 19039 |
19039 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19040 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
19040 Instance::PrintJSONImpl(stream, ref); | 19041 Instance::PrintJSONImpl(stream, ref); |
19041 } | 19042 } |
19042 | 19043 |
19043 | 19044 |
19044 } // namespace dart | 19045 } // namespace dart |
OLD | NEW |