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 13662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13673 *(CharAddr(dststr, index)) = '\\'; | 13673 *(CharAddr(dststr, index)) = '\\'; |
| 13674 *(CharAddr(dststr, index + 1)) = SpecialCharacter(*CharAddr(str, i)); | 13674 *(CharAddr(dststr, index + 1)) = SpecialCharacter(*CharAddr(str, i)); |
| 13675 index += 2; | 13675 index += 2; |
| 13676 } else { | 13676 } else { |
| 13677 *(CharAddr(dststr, index)) = *CharAddr(str, i); | 13677 *(CharAddr(dststr, index)) = *CharAddr(str, i); |
| 13678 index += 1; | 13678 index += 1; |
| 13679 } | 13679 } |
| 13680 } | 13680 } |
| 13681 return OneByteString::raw(dststr); | 13681 return OneByteString::raw(dststr); |
| 13682 } | 13682 } |
| 13683 return OneByteString::New(static_cast<intptr_t>(0), Heap::kNew); | 13683 return OneByteString::raw(Symbols::Empty()); |
| 13684 } | 13684 } |
| 13685 | 13685 |
| 13686 RawOneByteString* ExternalOneByteString::EscapeSpecialCharacters( | 13686 RawOneByteString* ExternalOneByteString::EscapeSpecialCharacters( |
| 13687 const String& str) { | 13687 const String& str) { |
| 13688 intptr_t len = str.Length(); | 13688 intptr_t len = str.Length(); |
| 13689 if (len > 0) { | 13689 if (len > 0) { |
| 13690 intptr_t num_escapes = 0; | 13690 intptr_t num_escapes = 0; |
| 13691 for (intptr_t i = 0; i < len; i++) { | 13691 for (intptr_t i = 0; i < len; i++) { |
| 13692 if (IsSpecialCharacter(*CharAddr(str, i))) { | 13692 if (IsSpecialCharacter(*CharAddr(str, i))) { |
| 13693 num_escapes += 1; | 13693 num_escapes += 1; |
| 13694 } | 13694 } |
| 13695 } | 13695 } |
| 13696 const String& dststr = String::Handle( | 13696 const String& dststr = String::Handle( |
| 13697 OneByteString::New(len + num_escapes, Heap::kNew)); | 13697 OneByteString::New(len + num_escapes, Heap::kNew)); |
| 13698 intptr_t index = 0; | 13698 intptr_t index = 0; |
| 13699 for (intptr_t i = 0; i < len; i++) { | 13699 for (intptr_t i = 0; i < len; i++) { |
| 13700 if (IsSpecialCharacter(*CharAddr(str, i))) { | 13700 if (IsSpecialCharacter(*CharAddr(str, i))) { |
| 13701 *(OneByteString::CharAddr(dststr, index)) = '\\'; | 13701 *(OneByteString::CharAddr(dststr, index)) = '\\'; |
| 13702 *(OneByteString::CharAddr(dststr, index + 1)) = | 13702 *(OneByteString::CharAddr(dststr, index + 1)) = |
| 13703 SpecialCharacter(*CharAddr(str, i)); | 13703 SpecialCharacter(*CharAddr(str, i)); |
| 13704 index += 2; | 13704 index += 2; |
| 13705 } else { | 13705 } else { |
| 13706 *(OneByteString::CharAddr(dststr, index)) = *CharAddr(str, i); | 13706 *(OneByteString::CharAddr(dststr, index)) = *CharAddr(str, i); |
| 13707 index += 1; | 13707 index += 1; |
| 13708 } | 13708 } |
| 13709 } | 13709 } |
| 13710 return OneByteString::raw(dststr); | 13710 return OneByteString::raw(dststr); |
| 13711 } | 13711 } |
| 13712 return OneByteString::New(static_cast<intptr_t>(0), Heap::kNew); | 13712 return OneByteString::raw(Symbols::Empty()); |
| 13713 } | 13713 } |
| 13714 | 13714 |
| 13715 | 13715 |
| 13716 RawOneByteString* OneByteString::New(intptr_t len, | 13716 RawOneByteString* OneByteString::New(intptr_t len, |
| 13717 Heap::Space space) { | 13717 Heap::Space space) { |
| 13718 ASSERT(Isolate::Current() == Dart::vm_isolate() || | 13718 ASSERT(Isolate::Current() == Dart::vm_isolate() || |
| 13719 Isolate::Current()->object_store()->one_byte_string_class() != | 13719 Isolate::Current()->object_store()->one_byte_string_class() != |
| 13720 Class::null()); | 13720 Class::null()); |
| 13721 if (len < 0 || len > kMaxElements) { | 13721 if (len < 0 || len > kMaxElements) { |
| 13722 // This should be caught before we reach here. | 13722 // This should be caught before we reach here. |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13899 *(CharAddr(dststr, index)) = '\\'; | 13899 *(CharAddr(dststr, index)) = '\\'; |
| 13900 *(CharAddr(dststr, index + 1)) = SpecialCharacter(*CharAddr(str, i)); | 13900 *(CharAddr(dststr, index + 1)) = SpecialCharacter(*CharAddr(str, i)); |
| 13901 index += 2; | 13901 index += 2; |
| 13902 } else { | 13902 } else { |
| 13903 *(CharAddr(dststr, index)) = *CharAddr(str, i); | 13903 *(CharAddr(dststr, index)) = *CharAddr(str, i); |
| 13904 index += 1; | 13904 index += 1; |
| 13905 } | 13905 } |
| 13906 } | 13906 } |
| 13907 return TwoByteString::raw(dststr); | 13907 return TwoByteString::raw(dststr); |
| 13908 } | 13908 } |
| 13909 return TwoByteString::New(0, Heap::kNew); | 13909 return TwoByteString::raw(Symbols::Empty()); |
|
Ivan Posva
2013/10/01 03:14:22
Actually this is incorrect as Symbols::Empty is a
Jacob
2013/10/01 17:25:26
Switched this one back to calling
TwoByteString::N
| |
| 13910 } | 13910 } |
| 13911 | 13911 |
| 13912 | 13912 |
| 13913 RawTwoByteString* TwoByteString::New(intptr_t len, | 13913 RawTwoByteString* TwoByteString::New(intptr_t len, |
| 13914 Heap::Space space) { | 13914 Heap::Space space) { |
| 13915 ASSERT(Isolate::Current()->object_store()->two_byte_string_class()); | 13915 ASSERT(Isolate::Current()->object_store()->two_byte_string_class()); |
| 13916 if (len < 0 || len > kMaxElements) { | 13916 if (len < 0 || len > kMaxElements) { |
| 13917 // This should be caught before we reach here. | 13917 // This should be caught before we reach here. |
| 13918 FATAL1("Fatal error in TwoByteString::New: invalid len %" Pd "\n", len); | 13918 FATAL1("Fatal error in TwoByteString::New: invalid len %" Pd "\n", len); |
| 13919 } | 13919 } |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15219 return "_MirrorReference"; | 15219 return "_MirrorReference"; |
| 15220 } | 15220 } |
| 15221 | 15221 |
| 15222 | 15222 |
| 15223 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15223 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 15224 JSONObject jsobj(stream); | 15224 JSONObject jsobj(stream); |
| 15225 } | 15225 } |
| 15226 | 15226 |
| 15227 | 15227 |
| 15228 } // namespace dart | 15228 } // namespace dart |
| OLD | NEW |