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