OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 3296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3307 i::Handle<i::String> class_name = i::Handle<i::String>::cast(name); | 3307 i::Handle<i::String> class_name = i::Handle<i::String>::cast(name); |
3308 if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Arguments"))) { | 3308 if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Arguments"))) { |
3309 return v8::String::New("[object Object]"); | 3309 return v8::String::New("[object Object]"); |
3310 | 3310 |
3311 } else { | 3311 } else { |
3312 const char* prefix = "[object "; | 3312 const char* prefix = "[object "; |
3313 Local<String> str = Utils::ToLocal(class_name); | 3313 Local<String> str = Utils::ToLocal(class_name); |
3314 const char* postfix = "]"; | 3314 const char* postfix = "]"; |
3315 | 3315 |
3316 int prefix_len = i::StrLength(prefix); | 3316 int prefix_len = i::StrLength(prefix); |
3317 int str_len = str->Length(); | 3317 int str_len = str->Utf8Length(); |
3318 int postfix_len = i::StrLength(postfix); | 3318 int postfix_len = i::StrLength(postfix); |
3319 | 3319 |
3320 int buf_len = prefix_len + str_len + postfix_len; | 3320 int buf_len = prefix_len + str_len + postfix_len; |
3321 i::ScopedVector<char> buf(buf_len); | 3321 i::ScopedVector<char> buf(buf_len); |
3322 | 3322 |
3323 // Write prefix. | 3323 // Write prefix. |
3324 char* ptr = buf.start(); | 3324 char* ptr = buf.start(); |
3325 i::OS::MemCopy(ptr, prefix, prefix_len * v8::internal::kCharSize); | 3325 i::OS::MemCopy(ptr, prefix, prefix_len * v8::internal::kCharSize); |
3326 ptr += prefix_len; | 3326 ptr += prefix_len; |
3327 | 3327 |
3328 // Write real content. | 3328 // Write real content. |
3329 str->WriteAscii(ptr, 0, str_len); | 3329 str->WriteUtf8(ptr, str_len); |
3330 ptr += str_len; | 3330 ptr += str_len; |
3331 | 3331 |
3332 // Write postfix. | 3332 // Write postfix. |
3333 i::OS::MemCopy(ptr, postfix, postfix_len * v8::internal::kCharSize); | 3333 i::OS::MemCopy(ptr, postfix, postfix_len * v8::internal::kCharSize); |
3334 | 3334 |
3335 // Copy the buffer into a heap-allocated string and return it. | 3335 // Copy the buffer into a heap-allocated string and return it. |
3336 Local<String> result = v8::String::New(buf.start(), buf_len); | 3336 Local<String> result = v8::String::New(buf.start(), buf_len); |
3337 return result; | 3337 return result; |
3338 } | 3338 } |
3339 } | 3339 } |
(...skipping 3104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6444 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) | 6444 String::AsciiValue::AsciiValue(v8::Handle<v8::Value> obj) |
6445 : str_(NULL), length_(0) { | 6445 : str_(NULL), length_(0) { |
6446 i::Isolate* isolate = i::Isolate::Current(); | 6446 i::Isolate* isolate = i::Isolate::Current(); |
6447 if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return; | 6447 if (IsDeadCheck(isolate, "v8::String::AsciiValue::AsciiValue()")) return; |
6448 if (obj.IsEmpty()) return; | 6448 if (obj.IsEmpty()) return; |
6449 ENTER_V8(isolate); | 6449 ENTER_V8(isolate); |
6450 i::HandleScope scope(isolate); | 6450 i::HandleScope scope(isolate); |
6451 TryCatch try_catch; | 6451 TryCatch try_catch; |
6452 Handle<String> str = obj->ToString(); | 6452 Handle<String> str = obj->ToString(); |
6453 if (str.IsEmpty()) return; | 6453 if (str.IsEmpty()) return; |
6454 length_ = str->Length(); | 6454 length_ = str->Utf8Length(); |
6455 str_ = i::NewArray<char>(length_ + 1); | 6455 str_ = i::NewArray<char>(length_ + 1); |
6456 str->WriteAscii(str_); | 6456 str->WriteUtf8(str_); |
| 6457 ASSERT(i::String::NonAsciiStart(str_, length_) >= length_); |
6457 } | 6458 } |
6458 | 6459 |
6459 | 6460 |
6460 String::AsciiValue::~AsciiValue() { | 6461 String::AsciiValue::~AsciiValue() { |
6461 i::DeleteArray(str_); | 6462 i::DeleteArray(str_); |
6462 } | 6463 } |
6463 | 6464 |
6464 | 6465 |
6465 String::Value::Value(v8::Handle<v8::Value> obj) | 6466 String::Value::Value(v8::Handle<v8::Value> obj) |
6466 : str_(NULL), length_(0) { | 6467 : str_(NULL), length_(0) { |
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7635 | 7636 |
7636 v->VisitPointers(blocks_.first(), first_block_limit_); | 7637 v->VisitPointers(blocks_.first(), first_block_limit_); |
7637 | 7638 |
7638 for (int i = 1; i < blocks_.length(); i++) { | 7639 for (int i = 1; i < blocks_.length(); i++) { |
7639 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 7640 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |
7640 } | 7641 } |
7641 } | 7642 } |
7642 | 7643 |
7643 | 7644 |
7644 } } // namespace v8::internal | 7645 } } // namespace v8::internal |
OLD | NEW |