OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/execution.h" | 8 #include "src/execution.h" |
9 #include "src/heap/spaces-inl.h" | 9 #include "src/heap/spaces-inl.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 Factory* factory = isolate->factory(); | 131 Factory* factory = isolate->factory(); |
132 Handle<String> fmt_str = | 132 Handle<String> fmt_str = |
133 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("FormatMessage")); | 133 factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("FormatMessage")); |
134 Handle<JSFunction> fun = Handle<JSFunction>::cast(Object::GetProperty( | 134 Handle<JSFunction> fun = Handle<JSFunction>::cast(Object::GetProperty( |
135 isolate->js_builtins_object(), fmt_str).ToHandleChecked()); | 135 isolate->js_builtins_object(), fmt_str).ToHandleChecked()); |
136 Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data); | 136 Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data); |
137 Handle<Object> argv[] = { Handle<Object>(message->type(), isolate), | 137 Handle<Object> argv[] = { Handle<Object>(message->type(), isolate), |
138 Handle<Object>(message->arguments(), isolate) }; | 138 Handle<Object>(message->arguments(), isolate) }; |
139 | 139 |
140 MaybeHandle<Object> maybe_result = Execution::TryCall( | 140 MaybeHandle<Object> maybe_result = Execution::TryCall( |
141 fun, isolate->js_builtins_object(), ARRAY_SIZE(argv), argv); | 141 fun, isolate->js_builtins_object(), arraysize(argv), argv); |
142 Handle<Object> result; | 142 Handle<Object> result; |
143 if (!maybe_result.ToHandle(&result) || !result->IsString()) { | 143 if (!maybe_result.ToHandle(&result) || !result->IsString()) { |
144 return factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("<error>")); | 144 return factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("<error>")); |
145 } | 145 } |
146 Handle<String> result_string = Handle<String>::cast(result); | 146 Handle<String> result_string = Handle<String>::cast(result); |
147 // A string that has been obtained from JS code in this way is | 147 // A string that has been obtained from JS code in this way is |
148 // likely to be a complicated ConsString of some sort. We flatten it | 148 // likely to be a complicated ConsString of some sort. We flatten it |
149 // here to improve the efficiency of converting it to a C string and | 149 // here to improve the efficiency of converting it to a C string and |
150 // other operations that are likely to take place (see GetLocalizedMessage | 150 // other operations that are likely to take place (see GetLocalizedMessage |
151 // for example). | 151 // for example). |
152 result_string = String::Flatten(result_string); | 152 result_string = String::Flatten(result_string); |
153 return result_string; | 153 return result_string; |
154 } | 154 } |
155 | 155 |
156 | 156 |
157 SmartArrayPointer<char> MessageHandler::GetLocalizedMessage( | 157 SmartArrayPointer<char> MessageHandler::GetLocalizedMessage( |
158 Isolate* isolate, | 158 Isolate* isolate, |
159 Handle<Object> data) { | 159 Handle<Object> data) { |
160 HandleScope scope(isolate); | 160 HandleScope scope(isolate); |
161 return GetMessage(isolate, data)->ToCString(DISALLOW_NULLS); | 161 return GetMessage(isolate, data)->ToCString(DISALLOW_NULLS); |
162 } | 162 } |
163 | 163 |
164 | 164 |
165 } } // namespace v8::internal | 165 } } // namespace v8::internal |
OLD | NEW |