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 16889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16900 // TODO(cshapiro): create a fast-path for OneByteString instances. | 16900 // TODO(cshapiro): create a fast-path for OneByteString instances. |
| 16901 return Transform(CaseMapping::ToUpper, str, space); | 16901 return Transform(CaseMapping::ToUpper, str, space); |
| 16902 } | 16902 } |
| 16903 | 16903 |
| 16904 | 16904 |
| 16905 RawString* String::ToLowerCase(const String& str, Heap::Space space) { | 16905 RawString* String::ToLowerCase(const String& str, Heap::Space space) { |
| 16906 // TODO(cshapiro): create a fast-path for OneByteString instances. | 16906 // TODO(cshapiro): create a fast-path for OneByteString instances. |
| 16907 return Transform(CaseMapping::ToLower, str, space); | 16907 return Transform(CaseMapping::ToLower, str, space); |
| 16908 } | 16908 } |
| 16909 | 16909 |
| 16910 bool String::ParseDouble(const String& str, | |
| 16911 intptr_t start, intptr_t end, | |
| 16912 double* result) { | |
| 16913 ASSERT(0 <= start); | |
| 16914 ASSERT(start <= end); | |
| 16915 ASSERT(end <= str.Length()); | |
| 16916 int length = end - start; | |
|
Ivan Posva
2014/07/03 19:44:14
Please always use intptr_t.
Lasse Reichstein Nielsen
2014/07/04 06:46:01
Ack, yes. Will do.
| |
| 16917 NoGCScope no_gc; | |
| 16918 const uint8_t* startChar; | |
| 16919 if (str.IsOneByteString()) { | |
| 16920 startChar = OneByteString::CharAddr(str, start); | |
| 16921 } else if (str.IsExternalOneByteString()) { | |
| 16922 startChar = ExternalOneByteString::CharAddr(str, start); | |
| 16923 } else { | |
| 16924 uint8_t* chars = Isolate::Current()->current_zone()->Alloc<uint8_t>(length); | |
| 16925 for (int i = 0; i < length; i++) { | |
|
Ivan Posva
2014/07/03 19:44:14
intptr_t
| |
| 16926 int ch = str.CharAt(start + i); | |
|
Ivan Posva
2014/07/03 19:44:14
The return type of CharAt is int32_t.
Also it wou
Lasse Reichstein Nielsen
2014/07/04 06:46:01
Will do.
Didn't know about the CharAtFunc - nice!
| |
| 16927 if (ch < 128) { | |
| 16928 chars[i] = ch; | |
| 16929 } else { | |
| 16930 return false; // Not ASCII, so definitely not valid double numeral. | |
| 16931 } | |
| 16932 } | |
| 16933 startChar = chars; | |
| 16934 } | |
| 16935 return CStringToDouble(reinterpret_cast<const char*>(startChar), | |
| 16936 length, result); | |
| 16937 } | |
| 16938 | |
| 16910 | 16939 |
| 16911 // Check to see if 'str1' matches 'str2' as is or | 16940 // Check to see if 'str1' matches 'str2' as is or |
| 16912 // once the private key separator is stripped from str2. | 16941 // once the private key separator is stripped from str2. |
| 16913 // | 16942 // |
| 16914 // Things are made more complicated by the fact that constructors are | 16943 // Things are made more complicated by the fact that constructors are |
| 16915 // added *after* the private suffix, so "foo@123.named" should match | 16944 // added *after* the private suffix, so "foo@123.named" should match |
| 16916 // "foo.named". | 16945 // "foo.named". |
| 16917 // | 16946 // |
| 16918 // Also, the private suffix can occur more than once in the name, as in: | 16947 // Also, the private suffix can occur more than once in the name, as in: |
| 16919 // | 16948 // |
| (...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 18992 return tag_label.ToCString(); | 19021 return tag_label.ToCString(); |
| 18993 } | 19022 } |
| 18994 | 19023 |
| 18995 | 19024 |
| 18996 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19025 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 18997 Instance::PrintJSONImpl(stream, ref); | 19026 Instance::PrintJSONImpl(stream, ref); |
| 18998 } | 19027 } |
| 18999 | 19028 |
| 19000 | 19029 |
| 19001 } // namespace dart | 19030 } // namespace dart |
| OLD | NEW |