Chromium Code Reviews| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 result ^= OneByteString::New(temp, len, Heap::kNew); | 47 result ^= OneByteString::New(temp, len, Heap::kNew); |
| 48 } else if (is_two_byte_string) { | 48 } else if (is_two_byte_string) { |
| 49 result ^= TwoByteString::New(temp, len, Heap::kNew); | 49 result ^= TwoByteString::New(temp, len, Heap::kNew); |
| 50 } else { | 50 } else { |
| 51 result ^= FourByteString::New(temp, len, Heap::kNew); | 51 result ^= FourByteString::New(temp, len, Heap::kNew); |
| 52 } | 52 } |
| 53 arguments->SetReturn(result); | 53 arguments->SetReturn(result); |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 DEFINE_NATIVE_ENTRY(StringBase_substringUnchecked, 3) { | |
| 58 GET_NATIVE_ARGUMENT(String, receiver, arguments->At(0)); | |
| 59 GET_NATIVE_ARGUMENT(Smi, start_obj, arguments->At(1)); | |
| 60 GET_NATIVE_ARGUMENT(Smi, end_obj, arguments->At(2)); | |
| 61 | |
| 62 intptr_t start = start_obj.Value(); | |
| 63 intptr_t end = end_obj.Value(); | |
| 64 | |
| 65 const String& result = String::Handle( | |
| 66 String::SubString(receiver, start, (end - start))); | |
| 67 arguments->SetReturn(result); | |
| 68 } | |
| 69 | |
|
Ivan Posva
2012/08/23 21:34:06
One too many lines.
| |
| 70 | |
| 71 | |
| 57 DEFINE_NATIVE_ENTRY(String_hashCode, 1) { | 72 DEFINE_NATIVE_ENTRY(String_hashCode, 1) { |
| 58 const String& receiver = String::CheckedHandle(arguments->At(0)); | 73 const String& receiver = String::CheckedHandle(arguments->At(0)); |
| 59 intptr_t hash_val = receiver.Hash(); | 74 intptr_t hash_val = receiver.Hash(); |
| 60 ASSERT(hash_val > 0); | 75 ASSERT(hash_val > 0); |
| 61 ASSERT(Smi::IsValid(hash_val)); | 76 ASSERT(Smi::IsValid(hash_val)); |
| 62 const Smi& hash_smi = Smi::Handle(Smi::New(hash_val)); | 77 const Smi& hash_smi = Smi::Handle(Smi::New(hash_val)); |
| 63 arguments->SetReturn(hash_smi); | 78 arguments->SetReturn(hash_smi); |
| 64 } | 79 } |
| 65 | 80 |
| 66 | 81 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 GrowableArray<const Object*> args; | 163 GrowableArray<const Object*> args; |
| 149 args.Add(&elem); | 164 args.Add(&elem); |
| 150 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); | 165 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); |
| 151 } | 166 } |
| 152 } | 167 } |
| 153 const String& result = String::Handle(String::ConcatAll(strings)); | 168 const String& result = String::Handle(String::ConcatAll(strings)); |
| 154 arguments->SetReturn(result); | 169 arguments->SetReturn(result); |
| 155 } | 170 } |
| 156 | 171 |
| 157 } // namespace dart | 172 } // namespace dart |
| OLD | NEW |