| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 | 847 |
| 848 Handle<Object> Factory::NewReferenceError(Handle<String> message) { | 848 Handle<Object> Factory::NewReferenceError(Handle<String> message) { |
| 849 return NewError("$ReferenceError", message); | 849 return NewError("$ReferenceError", message); |
| 850 } | 850 } |
| 851 | 851 |
| 852 | 852 |
| 853 Handle<Object> Factory::NewError(const char* maker, | 853 Handle<Object> Factory::NewError(const char* maker, |
| 854 const char* message, | 854 const char* message, |
| 855 Vector< Handle<Object> > args) { | 855 Vector< Handle<Object> > args) { |
| 856 // Instantiate a closeable HandleScope for EscapeFrom. | 856 // Instantiate a closeable HandleScope for EscapeFrom. |
| 857 v8::HandleScope scope(reinterpret_cast<v8::Isolate*>(isolate())); | 857 v8::EscapableHandleScope scope(reinterpret_cast<v8::Isolate*>(isolate())); |
| 858 Handle<FixedArray> array = NewFixedArray(args.length()); | 858 Handle<FixedArray> array = NewFixedArray(args.length()); |
| 859 for (int i = 0; i < args.length(); i++) { | 859 for (int i = 0; i < args.length(); i++) { |
| 860 array->set(i, *args[i]); | 860 array->set(i, *args[i]); |
| 861 } | 861 } |
| 862 Handle<JSArray> object = NewJSArrayWithElements(array); | 862 Handle<JSArray> object = NewJSArrayWithElements(array); |
| 863 Handle<Object> result = NewError(maker, message, object); | 863 Handle<Object> result = NewError(maker, message, object); |
| 864 return result.EscapeFrom(&scope); | 864 return result.EscapeFrom(&scope); |
| 865 } | 865 } |
| 866 | 866 |
| 867 | 867 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 889 space -= Min(space, strlen(message)); | 889 space -= Min(space, strlen(message)); |
| 890 p = &buffer[kBufferSize] - space; | 890 p = &buffer[kBufferSize] - space; |
| 891 | 891 |
| 892 for (unsigned i = 0; i < ARRAY_SIZE(args); i++) { | 892 for (unsigned i = 0; i < ARRAY_SIZE(args); i++) { |
| 893 if (space > 0) { | 893 if (space > 0) { |
| 894 *p++ = ' '; | 894 *p++ = ' '; |
| 895 space--; | 895 space--; |
| 896 if (space > 0) { | 896 if (space > 0) { |
| 897 MaybeObject* maybe_arg = args->GetElement(isolate(), i); | 897 MaybeObject* maybe_arg = args->GetElement(isolate(), i); |
| 898 Handle<String> arg_str(reinterpret_cast<String*>(maybe_arg)); | 898 Handle<String> arg_str(reinterpret_cast<String*>(maybe_arg)); |
| 899 const char* arg = *arg_str->ToCString(); | 899 SmartArrayPointer<char> arg = arg_str->ToCString(); |
| 900 Vector<char> v2(p, static_cast<int>(space)); | 900 Vector<char> v2(p, static_cast<int>(space)); |
| 901 OS::StrNCpy(v2, arg, space); | 901 OS::StrNCpy(v2, arg.get(), space); |
| 902 space -= Min(space, strlen(arg)); | 902 space -= Min(space, strlen(arg.get())); |
| 903 p = &buffer[kBufferSize] - space; | 903 p = &buffer[kBufferSize] - space; |
| 904 } | 904 } |
| 905 } | 905 } |
| 906 } | 906 } |
| 907 if (space > 0) { | 907 if (space > 0) { |
| 908 *p = '\0'; | 908 *p = '\0'; |
| 909 } else { | 909 } else { |
| 910 buffer[kBufferSize - 1] = '\0'; | 910 buffer[kBufferSize - 1] = '\0'; |
| 911 } | 911 } |
| 912 Handle<String> error_string = NewStringFromUtf8(CStrVector(buffer), TENURED); | 912 Handle<String> error_string = NewStringFromUtf8(CStrVector(buffer), TENURED); |
| (...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 return Handle<Object>::null(); | 1797 return Handle<Object>::null(); |
| 1798 } | 1798 } |
| 1799 | 1799 |
| 1800 | 1800 |
| 1801 Handle<Object> Factory::ToBoolean(bool value) { | 1801 Handle<Object> Factory::ToBoolean(bool value) { |
| 1802 return value ? true_value() : false_value(); | 1802 return value ? true_value() : false_value(); |
| 1803 } | 1803 } |
| 1804 | 1804 |
| 1805 | 1805 |
| 1806 } } // namespace v8::internal | 1806 } } // namespace v8::internal |
| OLD | NEW |