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 | 5 |
6 #ifdef V8_I18N_SUPPORT | 6 #ifdef V8_I18N_SUPPORT |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/api-natives.h" | 9 #include "src/api-natives.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
11 #include "src/i18n.h" | 11 #include "src/i18n.h" |
12 #include "src/messages.h" | |
13 #include "src/runtime/runtime-utils.h" | 12 #include "src/runtime/runtime-utils.h" |
14 | 13 |
15 #include "unicode/brkiter.h" | 14 #include "unicode/brkiter.h" |
16 #include "unicode/calendar.h" | 15 #include "unicode/calendar.h" |
17 #include "unicode/coll.h" | 16 #include "unicode/coll.h" |
18 #include "unicode/curramt.h" | 17 #include "unicode/curramt.h" |
19 #include "unicode/datefmt.h" | 18 #include "unicode/datefmt.h" |
20 #include "unicode/dcfmtsym.h" | 19 #include "unicode/dcfmtsym.h" |
21 #include "unicode/decimfmt.h" | 20 #include "unicode/decimfmt.h" |
22 #include "unicode/dtfmtsym.h" | 21 #include "unicode/dtfmtsym.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 HandleScope scope(isolate); | 227 HandleScope scope(isolate); |
229 | 228 |
230 DCHECK(args.length() == 1); | 229 DCHECK(args.length() == 1); |
231 | 230 |
232 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 231 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
233 | 232 |
234 if (!input->IsJSObject()) return isolate->heap()->false_value(); | 233 if (!input->IsJSObject()) return isolate->heap()->false_value(); |
235 Handle<JSObject> obj = Handle<JSObject>::cast(input); | 234 Handle<JSObject> obj = Handle<JSObject>::cast(input); |
236 | 235 |
237 Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol(); | 236 Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol(); |
238 Handle<Object> tag = JSReceiver::GetDataProperty(obj, marker); | 237 Handle<Object> tag = JSObject::GetDataProperty(obj, marker); |
239 return isolate->heap()->ToBoolean(!tag->IsUndefined()); | 238 return isolate->heap()->ToBoolean(!tag->IsUndefined()); |
240 } | 239 } |
241 | 240 |
242 | 241 |
243 RUNTIME_FUNCTION(Runtime_IsInitializedIntlObjectOfType) { | 242 RUNTIME_FUNCTION(Runtime_IsInitializedIntlObjectOfType) { |
244 HandleScope scope(isolate); | 243 HandleScope scope(isolate); |
245 | 244 |
246 DCHECK(args.length() == 2); | 245 DCHECK(args.length() == 2); |
247 | 246 |
248 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 247 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
249 CONVERT_ARG_HANDLE_CHECKED(String, expected_type, 1); | 248 CONVERT_ARG_HANDLE_CHECKED(String, expected_type, 1); |
250 | 249 |
251 if (!input->IsJSObject()) return isolate->heap()->false_value(); | 250 if (!input->IsJSObject()) return isolate->heap()->false_value(); |
252 Handle<JSObject> obj = Handle<JSObject>::cast(input); | 251 Handle<JSObject> obj = Handle<JSObject>::cast(input); |
253 | 252 |
254 Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol(); | 253 Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol(); |
255 Handle<Object> tag = JSReceiver::GetDataProperty(obj, marker); | 254 Handle<Object> tag = JSObject::GetDataProperty(obj, marker); |
256 return isolate->heap()->ToBoolean(tag->IsString() && | 255 return isolate->heap()->ToBoolean(tag->IsString() && |
257 String::cast(*tag)->Equals(*expected_type)); | 256 String::cast(*tag)->Equals(*expected_type)); |
258 } | 257 } |
259 | 258 |
260 | 259 |
261 RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) { | 260 RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) { |
262 HandleScope scope(isolate); | 261 HandleScope scope(isolate); |
263 | 262 |
264 DCHECK(args.length() == 3); | 263 DCHECK(args.length() == 3); |
265 | 264 |
266 CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0); | 265 CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0); |
267 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); | 266 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); |
268 CONVERT_ARG_HANDLE_CHECKED(JSObject, impl, 2); | 267 CONVERT_ARG_HANDLE_CHECKED(JSObject, impl, 2); |
269 | 268 |
270 Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol(); | 269 Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol(); |
271 JSObject::SetProperty(input, marker, type, STRICT).Assert(); | 270 JSObject::SetProperty(input, marker, type, STRICT).Assert(); |
272 | 271 |
273 marker = isolate->factory()->intl_impl_object_symbol(); | 272 marker = isolate->factory()->intl_impl_object_symbol(); |
274 JSObject::SetProperty(input, marker, impl, STRICT).Assert(); | 273 JSObject::SetProperty(input, marker, impl, STRICT).Assert(); |
275 | 274 |
276 return isolate->heap()->undefined_value(); | 275 return isolate->heap()->undefined_value(); |
277 } | 276 } |
278 | 277 |
279 | 278 |
280 RUNTIME_FUNCTION(Runtime_GetImplFromInitializedIntlObject) { | 279 RUNTIME_FUNCTION(Runtime_GetImplFromInitializedIntlObject) { |
281 HandleScope scope(isolate); | 280 HandleScope scope(isolate); |
282 | 281 |
283 DCHECK(args.length() == 1); | 282 DCHECK(args.length() == 1); |
284 | 283 |
285 CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0); | 284 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
286 | 285 |
287 if (!input->IsJSObject()) { | 286 if (!input->IsJSObject()) { |
288 THROW_NEW_ERROR_RETURN_FAILURE( | 287 Vector<Handle<Object> > arguments = HandleVector(&input, 1); |
289 isolate, NewTypeError(MessageTemplate::kNotIntlObject, input)); | 288 THROW_NEW_ERROR_RETURN_FAILURE(isolate, |
| 289 NewTypeError("not_intl_object", arguments)); |
290 } | 290 } |
291 | 291 |
292 Handle<JSObject> obj = Handle<JSObject>::cast(input); | 292 Handle<JSObject> obj = Handle<JSObject>::cast(input); |
293 | 293 |
294 Handle<Symbol> marker = isolate->factory()->intl_impl_object_symbol(); | 294 Handle<Symbol> marker = isolate->factory()->intl_impl_object_symbol(); |
295 | 295 |
296 Handle<Object> impl = JSReceiver::GetDataProperty(obj, marker); | 296 Handle<Object> impl = JSObject::GetDataProperty(obj, marker); |
297 if (impl->IsTheHole()) { | 297 if (impl->IsTheHole()) { |
298 THROW_NEW_ERROR_RETURN_FAILURE( | 298 Vector<Handle<Object> > arguments = HandleVector(&obj, 1); |
299 isolate, NewTypeError(MessageTemplate::kNotIntlObject, obj)); | 299 THROW_NEW_ERROR_RETURN_FAILURE(isolate, |
| 300 NewTypeError("not_intl_object", arguments)); |
300 } | 301 } |
301 return *impl; | 302 return *impl; |
302 } | 303 } |
303 | 304 |
304 | 305 |
305 RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) { | 306 RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) { |
306 HandleScope scope(isolate); | 307 HandleScope scope(isolate); |
307 | 308 |
308 DCHECK(args.length() == 3); | 309 DCHECK(args.length() == 3); |
309 | 310 |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 } else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) { | 743 } else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) { |
743 return *isolate->factory()->NewStringFromStaticChars("ideo"); | 744 return *isolate->factory()->NewStringFromStaticChars("ideo"); |
744 } else { | 745 } else { |
745 return *isolate->factory()->NewStringFromStaticChars("unknown"); | 746 return *isolate->factory()->NewStringFromStaticChars("unknown"); |
746 } | 747 } |
747 } | 748 } |
748 } | 749 } |
749 } // namespace v8::internal | 750 } // namespace v8::internal |
750 | 751 |
751 #endif // V8_I18N_SUPPORT | 752 #endif // V8_I18N_SUPPORT |
OLD | NEW |