| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
| 6 | 6 |
| 7 #include "vm/exceptions.h" | 7 #include "vm/exceptions.h" |
| 8 #include "vm/native_entry.h" | 8 #include "vm/native_entry.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 utf32_array[i] = value; | 44 utf32_array[i] = value; |
| 45 } | 45 } |
| 46 if (is_one_byte_string) { | 46 if (is_one_byte_string) { |
| 47 return OneByteString::New(utf32_array, array_len, Heap::kNew); | 47 return OneByteString::New(utf32_array, array_len, Heap::kNew); |
| 48 } | 48 } |
| 49 return TwoByteString::New(utf16_len, utf32_array, array_len, Heap::kNew); | 49 return TwoByteString::New(utf16_len, utf32_array, array_len, Heap::kNew); |
| 50 } | 50 } |
| 51 | 51 |
| 52 | 52 |
| 53 DEFINE_NATIVE_ENTRY(StringBase_substringUnchecked, 3) { | 53 DEFINE_NATIVE_ENTRY(StringBase_substringUnchecked, 3) { |
| 54 GET_NATIVE_ARGUMENT(String, receiver, arguments->NativeArgAt(0)); | 54 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0)); |
| 55 GET_NATIVE_ARGUMENT(Smi, start_obj, arguments->NativeArgAt(1)); | 55 GET_NATIVE_ARGUMENT(Smi, start_obj, arguments->NativeArgAt(1)); |
| 56 GET_NATIVE_ARGUMENT(Smi, end_obj, arguments->NativeArgAt(2)); | 56 GET_NATIVE_ARGUMENT(Smi, end_obj, arguments->NativeArgAt(2)); |
| 57 | 57 |
| 58 intptr_t start = start_obj.Value(); | 58 intptr_t start = start_obj.Value(); |
| 59 intptr_t end = end_obj.Value(); | 59 intptr_t end = end_obj.Value(); |
| 60 return String::SubString(receiver, start, (end - start)); | 60 return String::SubString(receiver, start, (end - start)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 | 63 |
| 64 DEFINE_NATIVE_ENTRY(OneByteString_substringUnchecked, 3) { |
| 65 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0)); |
| 66 ASSERT(receiver.IsOneByteString()); |
| 67 GET_NATIVE_ARGUMENT(Smi, start_obj, arguments->NativeArgAt(1)); |
| 68 GET_NATIVE_ARGUMENT(Smi, end_obj, arguments->NativeArgAt(2)); |
| 69 |
| 70 const intptr_t start = start_obj.Value(); |
| 71 const intptr_t end = end_obj.Value(); |
| 72 return OneByteString::New(receiver, start, end - start, Heap::kNew); |
| 73 } |
| 74 |
| 75 |
| 64 DEFINE_NATIVE_ENTRY(String_getHashCode, 1) { | 76 DEFINE_NATIVE_ENTRY(String_getHashCode, 1) { |
| 65 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0)); | 77 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0)); |
| 66 intptr_t hash_val = receiver.Hash(); | 78 intptr_t hash_val = receiver.Hash(); |
| 67 ASSERT(hash_val > 0); | 79 ASSERT(hash_val > 0); |
| 68 ASSERT(Smi::IsValid(hash_val)); | 80 ASSERT(Smi::IsValid(hash_val)); |
| 69 return Smi::New(hash_val); | 81 return Smi::New(hash_val); |
| 70 } | 82 } |
| 71 | 83 |
| 72 | 84 |
| 73 DEFINE_NATIVE_ENTRY(String_getLength, 1) { | 85 DEFINE_NATIVE_ENTRY(String_getLength, 1) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if (!elem.IsString()) { | 159 if (!elem.IsString()) { |
| 148 GrowableArray<const Object*> args; | 160 GrowableArray<const Object*> args; |
| 149 args.Add(&elem); | 161 args.Add(&elem); |
| 150 Exceptions::ThrowByType(Exceptions::kArgument, args); | 162 Exceptions::ThrowByType(Exceptions::kArgument, args); |
| 151 } | 163 } |
| 152 } | 164 } |
| 153 return String::ConcatAll(strings); | 165 return String::ConcatAll(strings); |
| 154 } | 166 } |
| 155 | 167 |
| 156 } // namespace dart | 168 } // namespace dart |
| OLD | NEW |