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 "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
(...skipping 7379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7390 symbol = String::SubString(str, begin_index, len, Heap::kOld); | 7390 symbol = String::SubString(str, begin_index, len, Heap::kOld); |
7391 } | 7391 } |
7392 symbol.SetHash(hash); | 7392 symbol.SetHash(hash); |
7393 InsertIntoSymbolTable(symbol_table, symbol, index, table_size); | 7393 InsertIntoSymbolTable(symbol_table, symbol, index, table_size); |
7394 } | 7394 } |
7395 ASSERT(symbol.IsSymbol()); | 7395 ASSERT(symbol.IsSymbol()); |
7396 return symbol.raw(); | 7396 return symbol.raw(); |
7397 } | 7397 } |
7398 | 7398 |
7399 | 7399 |
| 7400 RawString* String::NewFormatted(const char* format, ...) { |
| 7401 va_list args; |
| 7402 va_start(args, format); |
| 7403 intptr_t len = OS::VSNPrint(NULL, 0, format, args); |
| 7404 va_end(args); |
| 7405 |
| 7406 Zone* zone = Isolate::Current()->current_zone(); |
| 7407 char* buffer = reinterpret_cast<char*>(zone->Allocate(len + 1)); |
| 7408 va_list args2; |
| 7409 va_start(args2, format); |
| 7410 OS::VSNPrint(buffer, (len + 1), format, args2); |
| 7411 va_end(args2); |
| 7412 |
| 7413 return String::New(buffer); |
| 7414 } |
| 7415 |
| 7416 |
7400 RawString* String::Concat(const String& str1, | 7417 RawString* String::Concat(const String& str1, |
7401 const String& str2, | 7418 const String& str2, |
7402 Heap::Space space) { | 7419 Heap::Space space) { |
7403 ASSERT(!str1.IsNull() && !str2.IsNull()); | 7420 ASSERT(!str1.IsNull() && !str2.IsNull()); |
7404 intptr_t char_size = Utils::Maximum(str1.CharSize(), str2.CharSize()); | 7421 intptr_t char_size = Utils::Maximum(str1.CharSize(), str2.CharSize()); |
7405 if (char_size == kFourByteChar) { | 7422 if (char_size == kFourByteChar) { |
7406 return FourByteString::Concat(str1, str2, space); | 7423 return FourByteString::Concat(str1, str2, space); |
7407 } | 7424 } |
7408 if (char_size == kTwoByteChar) { | 7425 if (char_size == kTwoByteChar) { |
7409 return TwoByteString::Concat(str1, str2, space); | 7426 return TwoByteString::Concat(str1, str2, space); |
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8836 result.set_num_args_tested(num_args_tested); | 8853 result.set_num_args_tested(num_args_tested); |
8837 // Number of array elements in one test entry (num_args_tested + 1) | 8854 // Number of array elements in one test entry (num_args_tested + 1) |
8838 intptr_t len = result.TestEntryLength(); | 8855 intptr_t len = result.TestEntryLength(); |
8839 // IC data array must be null terminated (sentinel entry). | 8856 // IC data array must be null terminated (sentinel entry). |
8840 const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); | 8857 const Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); |
8841 result.set_ic_data(ic_data); | 8858 result.set_ic_data(ic_data); |
8842 return result.raw(); | 8859 return result.raw(); |
8843 } | 8860 } |
8844 | 8861 |
8845 } // namespace dart | 8862 } // namespace dart |
OLD | NEW |