|
17 | 17 | #include "ecma-builtins.h" |
18 | 18 | #include "ecma-conversion.h" |
19 | 19 | #include "ecma-exceptions.h" |
| 20 | +#include "ecma-function-object.h" |
20 | 21 | #include "ecma-gc.h" |
21 | 22 | #include "ecma-globals.h" |
22 | 23 | #include "ecma-helpers.h" |
@@ -157,7 +158,38 @@ ecma_builtin_object_prototype_object_value_of (ecma_value_t this_arg) /**< this |
157 | 158 | static ecma_completion_value_t |
158 | 159 | ecma_builtin_object_prototype_object_to_locale_string (ecma_value_t this_arg) /**< this argument */ |
159 | 160 | { |
160 | | - ECMA_BUILTIN_CP_UNIMPLEMENTED (this_arg); |
| 161 | + ecma_completion_value_t return_value = ecma_make_empty_completion_value (); |
| 162 | + /* 1. */ |
| 163 | + ECMA_TRY_CATCH (obj_val, |
| 164 | + ecma_op_to_object (this_arg), |
| 165 | + return_value); |
| 166 | + |
| 167 | + ecma_object_t *obj_p = ecma_get_object_from_value (obj_val); |
| 168 | + ecma_string_t *to_string_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_TO_STRING_UL); |
| 169 | + |
| 170 | + /* 2. */ |
| 171 | + ECMA_TRY_CATCH (to_string_val, |
| 172 | + ecma_op_object_get (obj_p, to_string_magic_string_p), |
| 173 | + return_value); |
| 174 | + |
| 175 | + /* 3. */ |
| 176 | + if (!ecma_op_is_callable (to_string_val)) |
| 177 | + { |
| 178 | + return_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE)); |
| 179 | + } |
| 180 | + else |
| 181 | + { |
| 182 | + /* 4. */ |
| 183 | + ecma_object_t *to_string_func_obj_p = ecma_get_object_from_value (to_string_val); |
| 184 | + return_value = ecma_op_function_call (to_string_func_obj_p, this_arg, NULL, 0); |
| 185 | + } |
| 186 | + ECMA_FINALIZE (to_string_val) |
| 187 | + |
| 188 | + ecma_deref_ecma_string (to_string_magic_string_p); |
| 189 | + |
| 190 | + ECMA_FINALIZE (obj_val) |
| 191 | + |
| 192 | + return return_value; |
161 | 193 | } /* ecma_builtin_object_prototype_object_to_locale_string */ |
162 | 194 |
|
163 | 195 | /** |
|
0 commit comments