| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "factory.h" | 5 #include "factory.h" |
| 6 | 6 |
| 7 #include "isolate-inl.h" | 7 #include "isolate-inl.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 } | 1100 } |
| 1101 Handle<String> error_string = NewStringFromUtf8(CStrVector(buffer), TENURED); | 1101 Handle<String> error_string = NewStringFromUtf8(CStrVector(buffer), TENURED); |
| 1102 return error_string; | 1102 return error_string; |
| 1103 } | 1103 } |
| 1104 | 1104 |
| 1105 | 1105 |
| 1106 Handle<Object> Factory::NewError(const char* maker, | 1106 Handle<Object> Factory::NewError(const char* maker, |
| 1107 const char* message, | 1107 const char* message, |
| 1108 Handle<JSArray> args) { | 1108 Handle<JSArray> args) { |
| 1109 Handle<String> make_str = InternalizeUtf8String(maker); | 1109 Handle<String> make_str = InternalizeUtf8String(maker); |
| 1110 Handle<Object> fun_obj( | 1110 Handle<Object> fun_obj = GlobalObject::GetPropertyNoExceptionThrown( |
| 1111 isolate()->js_builtins_object()->GetPropertyNoExceptionThrown(*make_str), | 1111 isolate()->js_builtins_object(), make_str); |
| 1112 isolate()); | |
| 1113 // If the builtins haven't been properly configured yet this error | 1112 // If the builtins haven't been properly configured yet this error |
| 1114 // constructor may not have been defined. Bail out. | 1113 // constructor may not have been defined. Bail out. |
| 1115 if (!fun_obj->IsJSFunction()) { | 1114 if (!fun_obj->IsJSFunction()) { |
| 1116 return EmergencyNewError(message, args); | 1115 return EmergencyNewError(message, args); |
| 1117 } | 1116 } |
| 1118 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj); | 1117 Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj); |
| 1119 Handle<Object> message_obj = InternalizeUtf8String(message); | 1118 Handle<Object> message_obj = InternalizeUtf8String(message); |
| 1120 Handle<Object> argv[] = { message_obj, args }; | 1119 Handle<Object> argv[] = { message_obj, args }; |
| 1121 | 1120 |
| 1122 // Invoke the JavaScript factory method. If an exception is thrown while | 1121 // Invoke the JavaScript factory method. If an exception is thrown while |
| 1123 // running the factory method, use the exception as the result. | 1122 // running the factory method, use the exception as the result. |
| 1124 bool caught_exception; | 1123 bool caught_exception; |
| 1125 Handle<Object> result = Execution::TryCall(fun, | 1124 Handle<Object> result = Execution::TryCall(fun, |
| 1126 isolate()->js_builtins_object(), | 1125 isolate()->js_builtins_object(), |
| 1127 ARRAY_SIZE(argv), | 1126 ARRAY_SIZE(argv), |
| 1128 argv, | 1127 argv, |
| 1129 &caught_exception); | 1128 &caught_exception); |
| 1130 return result; | 1129 return result; |
| 1131 } | 1130 } |
| 1132 | 1131 |
| 1133 | 1132 |
| 1134 Handle<Object> Factory::NewError(Handle<String> message) { | 1133 Handle<Object> Factory::NewError(Handle<String> message) { |
| 1135 return NewError("$Error", message); | 1134 return NewError("$Error", message); |
| 1136 } | 1135 } |
| 1137 | 1136 |
| 1138 | 1137 |
| 1139 Handle<Object> Factory::NewError(const char* constructor, | 1138 Handle<Object> Factory::NewError(const char* constructor, |
| 1140 Handle<String> message) { | 1139 Handle<String> message) { |
| 1141 Handle<String> constr = InternalizeUtf8String(constructor); | 1140 Handle<String> constr = InternalizeUtf8String(constructor); |
| 1142 Handle<JSFunction> fun = Handle<JSFunction>( | 1141 Handle<JSFunction> fun = Handle<JSFunction>::cast( |
| 1143 JSFunction::cast(isolate()->js_builtins_object()-> | 1142 GlobalObject::GetPropertyNoExceptionThrown( |
| 1144 GetPropertyNoExceptionThrown(*constr))); | 1143 isolate()->js_builtins_object(), constr)); |
| 1145 Handle<Object> argv[] = { message }; | 1144 Handle<Object> argv[] = { message }; |
| 1146 | 1145 |
| 1147 // Invoke the JavaScript factory method. If an exception is thrown while | 1146 // Invoke the JavaScript factory method. If an exception is thrown while |
| 1148 // running the factory method, use the exception as the result. | 1147 // running the factory method, use the exception as the result. |
| 1149 bool caught_exception; | 1148 bool caught_exception; |
| 1150 Handle<Object> result = Execution::TryCall(fun, | 1149 Handle<Object> result = Execution::TryCall(fun, |
| 1151 isolate()->js_builtins_object(), | 1150 isolate()->js_builtins_object(), |
| 1152 ARRAY_SIZE(argv), | 1151 ARRAY_SIZE(argv), |
| 1153 argv, | 1152 argv, |
| 1154 &caught_exception); | 1153 &caught_exception); |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 if (name->Equals(h->infinity_string())) return infinity_value(); | 1977 if (name->Equals(h->infinity_string())) return infinity_value(); |
| 1979 return Handle<Object>::null(); | 1978 return Handle<Object>::null(); |
| 1980 } | 1979 } |
| 1981 | 1980 |
| 1982 | 1981 |
| 1983 Handle<Object> Factory::ToBoolean(bool value) { | 1982 Handle<Object> Factory::ToBoolean(bool value) { |
| 1984 return value ? true_value() : false_value(); | 1983 return value ? true_value() : false_value(); |
| 1985 } | 1984 } |
| 1986 | 1985 |
| 1987 } } // namespace v8::internal | 1986 } } // namespace v8::internal |
| OLD | NEW |