From 4160262ce841bc592239cac97006de8d75da1288 Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Thu, 30 Oct 2014 14:28:44 +0300 Subject: [PATCH] Implementing EvalError, RangeError, SyntaxError, URIError built-ins and corresponding prototype built-in objects. --- src/libcoreint/opcodes-helpers-variables.c | 6 +- src/libcoreint/opcodes.c | 6 +- .../ecma-builtin-evalerror-prototype.c | 33 +++++++ .../ecma-builtin-evalerror-prototype.inc.h | 65 +++++++++++++ src/libecmabuiltins/ecma-builtin-evalerror.c | 97 +++++++++++++++++++ .../ecma-builtin-evalerror.inc.h | 65 +++++++++++++ src/libecmabuiltins/ecma-builtin-global.inc.h | 40 ++++---- .../ecma-builtin-rangeerror-prototype.c | 33 +++++++ .../ecma-builtin-rangeerror-prototype.inc.h | 65 +++++++++++++ src/libecmabuiltins/ecma-builtin-rangeerror.c | 97 +++++++++++++++++++ .../ecma-builtin-rangeerror.inc.h | 65 +++++++++++++ .../ecma-builtin-referenceerror.inc.h | 2 +- .../ecma-builtin-syntaxerror-prototype.c | 33 +++++++ .../ecma-builtin-syntaxerror-prototype.inc.h | 65 +++++++++++++ .../ecma-builtin-syntaxerror.c | 97 +++++++++++++++++++ .../ecma-builtin-syntaxerror.inc.h | 65 +++++++++++++ .../ecma-builtin-typeerror.inc.h | 2 +- .../ecma-builtin-urierror-prototype.c | 33 +++++++ .../ecma-builtin-urierror-prototype.inc.h | 65 +++++++++++++ src/libecmabuiltins/ecma-builtin-urierror.c | 97 +++++++++++++++++++ .../ecma-builtin-urierror.inc.h | 65 +++++++++++++ src/libecmabuiltins/ecma-builtins-internal.h | 50 +++++++++- src/libecmaoperations/ecma-exceptions.c | 4 +- tests/jerry/error.js | 88 +++++++++++++++++ 24 files changed, 1205 insertions(+), 33 deletions(-) create mode 100644 src/libecmabuiltins/ecma-builtin-evalerror-prototype.c create mode 100644 src/libecmabuiltins/ecma-builtin-evalerror-prototype.inc.h create mode 100644 src/libecmabuiltins/ecma-builtin-evalerror.c create mode 100644 src/libecmabuiltins/ecma-builtin-evalerror.inc.h create mode 100644 src/libecmabuiltins/ecma-builtin-rangeerror-prototype.c create mode 100644 src/libecmabuiltins/ecma-builtin-rangeerror-prototype.inc.h create mode 100644 src/libecmabuiltins/ecma-builtin-rangeerror.c create mode 100644 src/libecmabuiltins/ecma-builtin-rangeerror.inc.h create mode 100644 src/libecmabuiltins/ecma-builtin-syntaxerror-prototype.c create mode 100644 src/libecmabuiltins/ecma-builtin-syntaxerror-prototype.inc.h create mode 100644 src/libecmabuiltins/ecma-builtin-syntaxerror.c create mode 100644 src/libecmabuiltins/ecma-builtin-syntaxerror.inc.h create mode 100644 src/libecmabuiltins/ecma-builtin-urierror-prototype.c create mode 100644 src/libecmabuiltins/ecma-builtin-urierror-prototype.inc.h create mode 100644 src/libecmabuiltins/ecma-builtin-urierror.c create mode 100644 src/libecmabuiltins/ecma-builtin-urierror.inc.h diff --git a/src/libcoreint/opcodes-helpers-variables.c b/src/libcoreint/opcodes-helpers-variables.c index 771ae2287..4f7d50f3f 100644 --- a/src/libcoreint/opcodes-helpers-variables.c +++ b/src/libcoreint/opcodes-helpers-variables.c @@ -104,7 +104,8 @@ get_variable_value (int_data_t *int_data, /**< interpreter context */ if (unlikely (do_eval_or_arguments_check && do_strict_eval_arguments_check (ref))) { - ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_SYNTAX)); + /* SyntaxError should be treated as an early error */ + JERRY_UNREACHABLE (); } else { @@ -156,7 +157,8 @@ set_variable_value (int_data_t *int_data, /**< interpreter context */ if (unlikely (do_strict_eval_arguments_check (ref))) { - ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_SYNTAX)); + /* SyntaxError should be treated as an early error */ + JERRY_UNREACHABLE (); } else { diff --git a/src/libcoreint/opcodes.c b/src/libcoreint/opcodes.c index 11b9ff971..5b771f3fc 100644 --- a/src/libcoreint/opcodes.c +++ b/src/libcoreint/opcodes.c @@ -1452,7 +1452,8 @@ opfunc_delete_var (opcode_t opdata, /**< operation data */ if (ref.is_strict) { - ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_SYNTAX)); + /* SyntaxError should be treated as an early error */ + JERRY_UNREACHABLE (); } else { @@ -1518,7 +1519,8 @@ opfunc_delete_prop (opcode_t opdata, /**< operation data */ { if (int_data->is_strict) { - ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_SYNTAX)); + /* SyntaxError should be treated as an early error */ + JERRY_UNREACHABLE (); } else { diff --git a/src/libecmabuiltins/ecma-builtin-evalerror-prototype.c b/src/libecmabuiltins/ecma-builtin-evalerror-prototype.c new file mode 100644 index 000000000..e6f58354b --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-evalerror-prototype.c @@ -0,0 +1,33 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ecma-alloc.h" +#include "ecma-builtins.h" +#include "ecma-conversion.h" +#include "ecma-exceptions.h" +#include "ecma-gc.h" +#include "ecma-globals.h" +#include "ecma-helpers.h" +#include "ecma-objects.h" +#include "ecma-string-object.h" +#include "ecma-try-catch-macro.h" +#include "globals.h" + +#define ECMA_BUILTINS_INTERNAL +#include "ecma-builtins-internal.h" + +#define BUILTIN_INC_HEADER_NAME "ecma-builtin-evalerror-prototype.inc.h" +#define BUILTIN_UNDERSCORED_ID eval_error_prototype +#include "ecma-builtin-internal-routines-template.inc.h" diff --git a/src/libecmabuiltins/ecma-builtin-evalerror-prototype.inc.h b/src/libecmabuiltins/ecma-builtin-evalerror-prototype.inc.h new file mode 100644 index 000000000..0e99d38dd --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-evalerror-prototype.inc.h @@ -0,0 +1,65 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * EvalError.prototype built-in description + */ + +#ifndef OBJECT_ID +# define OBJECT_ID(builtin_object_id) +#endif /* !OBJECT_ID */ + +#ifndef STRING_VALUE +# define STRING_VALUE(name, magic_string_id, prop_writable, prop_enumerable, prop_configurable) +#endif /* !STRING_VALUE */ + +#ifndef OBJECT_VALUE +# define OBJECT_VALUE(name, obj_getter, prop_writable, prop_enumerable, prop_configurable) +#endif /* !OBJECT_VALUE */ + +/* Object identifier */ +OBJECT_ID (ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE) + +/* Object properties: + * (property name, object pointer getter) */ + +// 15.11.7.8 +OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR, + ecma_builtin_get (ECMA_BUILTIN_ID_EVAL_ERROR), + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) + +// 15.11.7.9 +STRING_VALUE (ECMA_MAGIC_STRING_NAME, + ECMA_MAGIC_STRING_EVAL_ERROR_UL, + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) + +// 15.11.7.10 +STRING_VALUE (ECMA_MAGIC_STRING_MESSAGE, + ECMA_MAGIC_STRING__EMPTY, + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) + +#undef OBJECT_ID +#undef SIMPLE_VALUE +#undef NUMBER_VALUE +#undef STRING_VALUE +#undef OBJECT_VALUE +#undef CP_UNIMPLEMENTED_VALUE +#undef ROUTINE diff --git a/src/libecmabuiltins/ecma-builtin-evalerror.c b/src/libecmabuiltins/ecma-builtin-evalerror.c new file mode 100644 index 000000000..f4323a44a --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-evalerror.c @@ -0,0 +1,97 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ecma-alloc.h" +#include "ecma-builtins.h" +#include "ecma-conversion.h" +#include "ecma-exceptions.h" +#include "ecma-gc.h" +#include "ecma-globals.h" +#include "ecma-helpers.h" +#include "ecma-objects.h" +#include "ecma-try-catch-macro.h" +#include "globals.h" + +#define ECMA_BUILTINS_INTERNAL +#include "ecma-builtins-internal.h" + +#define BUILTIN_INC_HEADER_NAME "ecma-builtin-evalerror.inc.h" +#define BUILTIN_UNDERSCORED_ID eval_error +#include "ecma-builtin-internal-routines-template.inc.h" + +/** \addtogroup ecma ECMA + * @{ + * + * \addtogroup ecmabuiltins + * @{ + * + * \addtogroup evalerror ECMA EvalError object built-in + * @{ + */ + +/** + * Handle calling [[Call]] of built-in EvalError object + * + * @return completion-value + */ +ecma_completion_value_t +ecma_builtin_eval_error_dispatch_call (ecma_value_t *arguments_list_p, /**< arguments list */ + ecma_length_t arguments_list_len) /**< number of arguments */ +{ + JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); + + if (arguments_list_len != 0 + && !ecma_is_value_undefined (arguments_list_p [0])) + { + ecma_completion_value_t ret_value; + + ECMA_TRY_CATCH (msg_to_str_completion, + ecma_op_to_string (arguments_list_p[0]), + ret_value); + + ecma_string_t *message_string_p = ECMA_GET_POINTER (msg_to_str_completion.u.value.value); + ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_EVAL, + message_string_p); + ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p)); + + ECMA_FINALIZE (msg_to_str_completion); + + return ret_value; + } + else + { + ecma_object_t *new_error_object_p = ecma_new_standard_error (ECMA_ERROR_EVAL); + + return ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p)); + } +} /* ecma_builtin_eval_error_dispatch_call */ + +/** + * Handle calling [[Construct]] of built-in EvalError object + * + * @return completion-value + */ +ecma_completion_value_t +ecma_builtin_eval_error_dispatch_construct (ecma_value_t *arguments_list_p, /**< arguments list */ + ecma_length_t arguments_list_len) /**< number of arguments */ +{ + return ecma_builtin_eval_error_dispatch_call (arguments_list_p, arguments_list_len); +} /* ecma_builtin_eval_error_dispatch_construct */ + +/** + * @} + * @} + * @} + */ diff --git a/src/libecmabuiltins/ecma-builtin-evalerror.inc.h b/src/libecmabuiltins/ecma-builtin-evalerror.inc.h new file mode 100644 index 000000000..ffa2866de --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-evalerror.inc.h @@ -0,0 +1,65 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * EvalError built-in description + */ + +#ifndef OBJECT_ID +# define OBJECT_ID(builtin_object_id) +#endif /* !OBJECT_ID */ + +#ifndef NUMBER_VALUE +# define NUMBER_VALUE(name, number_value, prop_writable, prop_enumerable, prop_configurable) +#endif /* !NUMBER_VALUE */ + +#ifndef STRING_VALUE +# define STRING_VALUE(name, magic_string_id, prop_writable, prop_enumerable, prop_configurable) +#endif /* !STRING_VALUE */ + +#ifndef OBJECT_VALUE +# define OBJECT_VALUE(name, obj_getter, prop_writable, prop_enumerable, prop_configurable) +#endif /* !OBJECT_VALUE */ + +/* Object identifier */ +OBJECT_ID (ECMA_BUILTIN_ID_EVAL_ERROR) + +/* Number properties: + * (property name, number value, writable, enumerable, configurable) */ + +// 15.11.3 +NUMBER_VALUE (ECMA_MAGIC_STRING_LENGTH, + 1, + ECMA_PROPERTY_NOT_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_NOT_CONFIGURABLE) + +/* Object properties: + * (property name, object pointer getter) */ + +// 15.11.3.1 +OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE, + ecma_builtin_get (ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE), + ECMA_PROPERTY_NOT_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_NOT_CONFIGURABLE) + +#undef OBJECT_ID +#undef SIMPLE_VALUE +#undef NUMBER_VALUE +#undef STRING_VALUE +#undef OBJECT_VALUE +#undef CP_UNIMPLEMENTED_VALUE +#undef ROUTINE diff --git a/src/libecmabuiltins/ecma-builtin-global.inc.h b/src/libecmabuiltins/ecma-builtin-global.inc.h index 65e37b960..3d4586cc7 100644 --- a/src/libecmabuiltins/ecma-builtin-global.inc.h +++ b/src/libecmabuiltins/ecma-builtin-global.inc.h @@ -138,18 +138,18 @@ OBJECT_VALUE (ECMA_MAGIC_STRING_ERROR_UL, ECMA_PROPERTY_CONFIGURABLE) // ECMA-262 v5, 15.1.4.10 -CP_UNIMPLEMENTED_VALUE (ECMA_MAGIC_STRING_EVAL_ERROR_UL, - ecma_builtin_get (ECMA_BUILTIN_ID_EVAL_ERROR), - ECMA_PROPERTY_WRITABLE, - ECMA_PROPERTY_NOT_ENUMERABLE, - ECMA_PROPERTY_CONFIGURABLE) +OBJECT_VALUE (ECMA_MAGIC_STRING_EVAL_ERROR_UL, + ecma_builtin_get (ECMA_BUILTIN_ID_EVAL_ERROR), + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) // ECMA-262 v5, 15.1.4.11 -CP_UNIMPLEMENTED_VALUE (ECMA_MAGIC_STRING_RANGE_ERROR_UL, - ecma_builtin_get (ECMA_BUILTIN_ID_RANGE_ERROR), - ECMA_PROPERTY_WRITABLE, - ECMA_PROPERTY_NOT_ENUMERABLE, - ECMA_PROPERTY_CONFIGURABLE) +OBJECT_VALUE (ECMA_MAGIC_STRING_RANGE_ERROR_UL, + ecma_builtin_get (ECMA_BUILTIN_ID_RANGE_ERROR), + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) // ECMA-262 v5, 15.1.4.12 OBJECT_VALUE (ECMA_MAGIC_STRING_REFERENCE_ERROR_UL, @@ -159,11 +159,11 @@ OBJECT_VALUE (ECMA_MAGIC_STRING_REFERENCE_ERROR_UL, ECMA_PROPERTY_CONFIGURABLE) // ECMA-262 v5, 15.1.4.13 -CP_UNIMPLEMENTED_VALUE (ECMA_MAGIC_STRING_SYNTAX_ERROR_UL, - ecma_builtin_get (ECMA_BUILTIN_ID_SYNTAX_ERROR), - ECMA_PROPERTY_WRITABLE, - ECMA_PROPERTY_NOT_ENUMERABLE, - ECMA_PROPERTY_CONFIGURABLE) +OBJECT_VALUE (ECMA_MAGIC_STRING_SYNTAX_ERROR_UL, + ecma_builtin_get (ECMA_BUILTIN_ID_SYNTAX_ERROR), + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) // ECMA-262 v5, 15.1.4.14 OBJECT_VALUE (ECMA_MAGIC_STRING_TYPE_ERROR_UL, @@ -173,11 +173,11 @@ OBJECT_VALUE (ECMA_MAGIC_STRING_TYPE_ERROR_UL, ECMA_PROPERTY_CONFIGURABLE) // ECMA-262 v5, 15.1.4.15 -CP_UNIMPLEMENTED_VALUE (ECMA_MAGIC_STRING_URI_ERROR_UL, - ecma_builtin_get (ECMA_BUILTIN_ID_URI_ERROR), - ECMA_PROPERTY_WRITABLE, - ECMA_PROPERTY_NOT_ENUMERABLE, - ECMA_PROPERTY_CONFIGURABLE) +OBJECT_VALUE (ECMA_MAGIC_STRING_URI_ERROR_UL, + ecma_builtin_get (ECMA_BUILTIN_ID_URI_ERROR), + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) // ECMA-262 v5, 15.1.5.1 OBJECT_VALUE (ECMA_MAGIC_STRING_MATH_UL, diff --git a/src/libecmabuiltins/ecma-builtin-rangeerror-prototype.c b/src/libecmabuiltins/ecma-builtin-rangeerror-prototype.c new file mode 100644 index 000000000..8ff4268b2 --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-rangeerror-prototype.c @@ -0,0 +1,33 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ecma-alloc.h" +#include "ecma-builtins.h" +#include "ecma-conversion.h" +#include "ecma-exceptions.h" +#include "ecma-gc.h" +#include "ecma-globals.h" +#include "ecma-helpers.h" +#include "ecma-objects.h" +#include "ecma-string-object.h" +#include "ecma-try-catch-macro.h" +#include "globals.h" + +#define ECMA_BUILTINS_INTERNAL +#include "ecma-builtins-internal.h" + +#define BUILTIN_INC_HEADER_NAME "ecma-builtin-rangeerror-prototype.inc.h" +#define BUILTIN_UNDERSCORED_ID range_error_prototype +#include "ecma-builtin-internal-routines-template.inc.h" diff --git a/src/libecmabuiltins/ecma-builtin-rangeerror-prototype.inc.h b/src/libecmabuiltins/ecma-builtin-rangeerror-prototype.inc.h new file mode 100644 index 000000000..3bb70cb6f --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-rangeerror-prototype.inc.h @@ -0,0 +1,65 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * RangeError.prototype built-in description + */ + +#ifndef OBJECT_ID +# define OBJECT_ID(builtin_object_id) +#endif /* !OBJECT_ID */ + +#ifndef STRING_VALUE +# define STRING_VALUE(name, magic_string_id, prop_writable, prop_enumerable, prop_configurable) +#endif /* !STRING_VALUE */ + +#ifndef OBJECT_VALUE +# define OBJECT_VALUE(name, obj_getter, prop_writable, prop_enumerable, prop_configurable) +#endif /* !OBJECT_VALUE */ + +/* Object identifier */ +OBJECT_ID (ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE) + +/* Object properties: + * (property name, object pointer getter) */ + +// 15.11.7.8 +OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR, + ecma_builtin_get (ECMA_BUILTIN_ID_RANGE_ERROR), + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) + +// 15.11.7.9 +STRING_VALUE (ECMA_MAGIC_STRING_NAME, + ECMA_MAGIC_STRING_RANGE_ERROR_UL, + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) + +// 15.11.7.10 +STRING_VALUE (ECMA_MAGIC_STRING_MESSAGE, + ECMA_MAGIC_STRING__EMPTY, + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) + +#undef OBJECT_ID +#undef SIMPLE_VALUE +#undef NUMBER_VALUE +#undef STRING_VALUE +#undef OBJECT_VALUE +#undef CP_UNIMPLEMENTED_VALUE +#undef ROUTINE diff --git a/src/libecmabuiltins/ecma-builtin-rangeerror.c b/src/libecmabuiltins/ecma-builtin-rangeerror.c new file mode 100644 index 000000000..0ec776fc8 --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-rangeerror.c @@ -0,0 +1,97 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ecma-alloc.h" +#include "ecma-builtins.h" +#include "ecma-conversion.h" +#include "ecma-exceptions.h" +#include "ecma-gc.h" +#include "ecma-globals.h" +#include "ecma-helpers.h" +#include "ecma-objects.h" +#include "ecma-try-catch-macro.h" +#include "globals.h" + +#define ECMA_BUILTINS_INTERNAL +#include "ecma-builtins-internal.h" + +#define BUILTIN_INC_HEADER_NAME "ecma-builtin-rangeerror.inc.h" +#define BUILTIN_UNDERSCORED_ID range_error +#include "ecma-builtin-internal-routines-template.inc.h" + +/** \addtogroup ecma ECMA + * @{ + * + * \addtogroup ecmabuiltins + * @{ + * + * \addtogroup rangeerror ECMA RangeError object built-in + * @{ + */ + +/** + * Handle calling [[Call]] of built-in RangeError object + * + * @return completion-value + */ +ecma_completion_value_t +ecma_builtin_range_error_dispatch_call (ecma_value_t *arguments_list_p, /**< arguments list */ + ecma_length_t arguments_list_len) /**< number of arguments */ +{ + JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); + + if (arguments_list_len != 0 + && !ecma_is_value_undefined (arguments_list_p [0])) + { + ecma_completion_value_t ret_value; + + ECMA_TRY_CATCH (msg_to_str_completion, + ecma_op_to_string (arguments_list_p[0]), + ret_value); + + ecma_string_t *message_string_p = ECMA_GET_POINTER (msg_to_str_completion.u.value.value); + ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_RANGE, + message_string_p); + ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p)); + + ECMA_FINALIZE (msg_to_str_completion); + + return ret_value; + } + else + { + ecma_object_t *new_error_object_p = ecma_new_standard_error (ECMA_ERROR_RANGE); + + return ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p)); + } +} /* ecma_builtin_range_error_dispatch_call */ + +/** + * Handle calling [[Construct]] of built-in RangeError object + * + * @return completion-value + */ +ecma_completion_value_t +ecma_builtin_range_error_dispatch_construct (ecma_value_t *arguments_list_p, /**< arguments list */ + ecma_length_t arguments_list_len) /**< number of arguments */ +{ + return ecma_builtin_range_error_dispatch_call (arguments_list_p, arguments_list_len); +} /* ecma_builtin_range_error_dispatch_construct */ + +/** + * @} + * @} + * @} + */ diff --git a/src/libecmabuiltins/ecma-builtin-rangeerror.inc.h b/src/libecmabuiltins/ecma-builtin-rangeerror.inc.h new file mode 100644 index 000000000..3b53ad06e --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-rangeerror.inc.h @@ -0,0 +1,65 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * RangeError built-in description + */ + +#ifndef OBJECT_ID +# define OBJECT_ID(builtin_object_id) +#endif /* !OBJECT_ID */ + +#ifndef NUMBER_VALUE +# define NUMBER_VALUE(name, number_value, prop_writable, prop_enumerable, prop_configurable) +#endif /* !NUMBER_VALUE */ + +#ifndef STRING_VALUE +# define STRING_VALUE(name, magic_string_id, prop_writable, prop_enumerable, prop_configurable) +#endif /* !STRING_VALUE */ + +#ifndef OBJECT_VALUE +# define OBJECT_VALUE(name, obj_getter, prop_writable, prop_enumerable, prop_configurable) +#endif /* !OBJECT_VALUE */ + +/* Object identifier */ +OBJECT_ID (ECMA_BUILTIN_ID_RANGE_ERROR) + +/* Number properties: + * (property name, number value, writable, enumerable, configurable) */ + +// 15.11.3 +NUMBER_VALUE (ECMA_MAGIC_STRING_LENGTH, + 1, + ECMA_PROPERTY_NOT_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_NOT_CONFIGURABLE) + +/* Object properties: + * (property name, object pointer getter) */ + +// 15.11.3.1 +OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE, + ecma_builtin_get (ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE), + ECMA_PROPERTY_NOT_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_NOT_CONFIGURABLE) + +#undef OBJECT_ID +#undef SIMPLE_VALUE +#undef NUMBER_VALUE +#undef STRING_VALUE +#undef OBJECT_VALUE +#undef CP_UNIMPLEMENTED_VALUE +#undef ROUTINE diff --git a/src/libecmabuiltins/ecma-builtin-referenceerror.inc.h b/src/libecmabuiltins/ecma-builtin-referenceerror.inc.h index c6f53e97e..b73f9da70 100644 --- a/src/libecmabuiltins/ecma-builtin-referenceerror.inc.h +++ b/src/libecmabuiltins/ecma-builtin-referenceerror.inc.h @@ -49,7 +49,7 @@ NUMBER_VALUE (ECMA_MAGIC_STRING_LENGTH, /* Object properties: * (property name, object pointer getter) */ -// 15.7.3.1 +// 15.11.3.1 OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE, ecma_builtin_get (ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE), ECMA_PROPERTY_NOT_WRITABLE, diff --git a/src/libecmabuiltins/ecma-builtin-syntaxerror-prototype.c b/src/libecmabuiltins/ecma-builtin-syntaxerror-prototype.c new file mode 100644 index 000000000..6c6de9756 --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-syntaxerror-prototype.c @@ -0,0 +1,33 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ecma-alloc.h" +#include "ecma-builtins.h" +#include "ecma-conversion.h" +#include "ecma-exceptions.h" +#include "ecma-gc.h" +#include "ecma-globals.h" +#include "ecma-helpers.h" +#include "ecma-objects.h" +#include "ecma-string-object.h" +#include "ecma-try-catch-macro.h" +#include "globals.h" + +#define ECMA_BUILTINS_INTERNAL +#include "ecma-builtins-internal.h" + +#define BUILTIN_INC_HEADER_NAME "ecma-builtin-syntaxerror-prototype.inc.h" +#define BUILTIN_UNDERSCORED_ID syntax_error_prototype +#include "ecma-builtin-internal-routines-template.inc.h" diff --git a/src/libecmabuiltins/ecma-builtin-syntaxerror-prototype.inc.h b/src/libecmabuiltins/ecma-builtin-syntaxerror-prototype.inc.h new file mode 100644 index 000000000..e058f14c0 --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-syntaxerror-prototype.inc.h @@ -0,0 +1,65 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * SyntaxError.prototype built-in description + */ + +#ifndef OBJECT_ID +# define OBJECT_ID(builtin_object_id) +#endif /* !OBJECT_ID */ + +#ifndef STRING_VALUE +# define STRING_VALUE(name, magic_string_id, prop_writable, prop_enumerable, prop_configurable) +#endif /* !STRING_VALUE */ + +#ifndef OBJECT_VALUE +# define OBJECT_VALUE(name, obj_getter, prop_writable, prop_enumerable, prop_configurable) +#endif /* !OBJECT_VALUE */ + +/* Object identifier */ +OBJECT_ID (ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE) + +/* Object properties: + * (property name, object pointer getter) */ + +// 15.11.7.8 +OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR, + ecma_builtin_get (ECMA_BUILTIN_ID_SYNTAX_ERROR), + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) + +// 15.11.7.9 +STRING_VALUE (ECMA_MAGIC_STRING_NAME, + ECMA_MAGIC_STRING_SYNTAX_ERROR_UL, + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) + +// 15.11.7.10 +STRING_VALUE (ECMA_MAGIC_STRING_MESSAGE, + ECMA_MAGIC_STRING__EMPTY, + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) + +#undef OBJECT_ID +#undef SIMPLE_VALUE +#undef NUMBER_VALUE +#undef STRING_VALUE +#undef OBJECT_VALUE +#undef CP_UNIMPLEMENTED_VALUE +#undef ROUTINE diff --git a/src/libecmabuiltins/ecma-builtin-syntaxerror.c b/src/libecmabuiltins/ecma-builtin-syntaxerror.c new file mode 100644 index 000000000..ba0ac9f61 --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-syntaxerror.c @@ -0,0 +1,97 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ecma-alloc.h" +#include "ecma-builtins.h" +#include "ecma-conversion.h" +#include "ecma-exceptions.h" +#include "ecma-gc.h" +#include "ecma-globals.h" +#include "ecma-helpers.h" +#include "ecma-objects.h" +#include "ecma-try-catch-macro.h" +#include "globals.h" + +#define ECMA_BUILTINS_INTERNAL +#include "ecma-builtins-internal.h" + +#define BUILTIN_INC_HEADER_NAME "ecma-builtin-syntaxerror.inc.h" +#define BUILTIN_UNDERSCORED_ID syntax_error +#include "ecma-builtin-internal-routines-template.inc.h" + +/** \addtogroup ecma ECMA + * @{ + * + * \addtogroup ecmabuiltins + * @{ + * + * \addtogroup syntaxerror ECMA SyntaxError object built-in + * @{ + */ + +/** + * Handle calling [[Call]] of built-in SyntaxError object + * + * @return completion-value + */ +ecma_completion_value_t +ecma_builtin_syntax_error_dispatch_call (ecma_value_t *arguments_list_p, /**< arguments list */ + ecma_length_t arguments_list_len) /**< number of arguments */ +{ + JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); + + if (arguments_list_len != 0 + && !ecma_is_value_undefined (arguments_list_p [0])) + { + ecma_completion_value_t ret_value; + + ECMA_TRY_CATCH (msg_to_str_completion, + ecma_op_to_string (arguments_list_p[0]), + ret_value); + + ecma_string_t *message_string_p = ECMA_GET_POINTER (msg_to_str_completion.u.value.value); + ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_SYNTAX, + message_string_p); + ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p)); + + ECMA_FINALIZE (msg_to_str_completion); + + return ret_value; + } + else + { + ecma_object_t *new_error_object_p = ecma_new_standard_error (ECMA_ERROR_SYNTAX); + + return ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p)); + } +} /* ecma_builtin_syntax_error_dispatch_call */ + +/** + * Handle calling [[Construct]] of built-in SyntaxError object + * + * @return completion-value + */ +ecma_completion_value_t +ecma_builtin_syntax_error_dispatch_construct (ecma_value_t *arguments_list_p, /**< arguments list */ + ecma_length_t arguments_list_len) /**< number of arguments */ +{ + return ecma_builtin_syntax_error_dispatch_call (arguments_list_p, arguments_list_len); +} /* ecma_builtin_syntax_error_dispatch_construct */ + +/** + * @} + * @} + * @} + */ diff --git a/src/libecmabuiltins/ecma-builtin-syntaxerror.inc.h b/src/libecmabuiltins/ecma-builtin-syntaxerror.inc.h new file mode 100644 index 000000000..159868562 --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-syntaxerror.inc.h @@ -0,0 +1,65 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * SyntaxError built-in description + */ + +#ifndef OBJECT_ID +# define OBJECT_ID(builtin_object_id) +#endif /* !OBJECT_ID */ + +#ifndef NUMBER_VALUE +# define NUMBER_VALUE(name, number_value, prop_writable, prop_enumerable, prop_configurable) +#endif /* !NUMBER_VALUE */ + +#ifndef STRING_VALUE +# define STRING_VALUE(name, magic_string_id, prop_writable, prop_enumerable, prop_configurable) +#endif /* !STRING_VALUE */ + +#ifndef OBJECT_VALUE +# define OBJECT_VALUE(name, obj_getter, prop_writable, prop_enumerable, prop_configurable) +#endif /* !OBJECT_VALUE */ + +/* Object identifier */ +OBJECT_ID (ECMA_BUILTIN_ID_SYNTAX_ERROR) + +/* Number properties: + * (property name, number value, writable, enumerable, configurable) */ + +// 15.11.3 +NUMBER_VALUE (ECMA_MAGIC_STRING_LENGTH, + 1, + ECMA_PROPERTY_NOT_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_NOT_CONFIGURABLE) + +/* Object properties: + * (property name, object pointer getter) */ + +// 15.11.3.1 +OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE, + ecma_builtin_get (ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE), + ECMA_PROPERTY_NOT_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_NOT_CONFIGURABLE) + +#undef OBJECT_ID +#undef SIMPLE_VALUE +#undef NUMBER_VALUE +#undef STRING_VALUE +#undef OBJECT_VALUE +#undef CP_UNIMPLEMENTED_VALUE +#undef ROUTINE diff --git a/src/libecmabuiltins/ecma-builtin-typeerror.inc.h b/src/libecmabuiltins/ecma-builtin-typeerror.inc.h index 3326c0de5..1bc08c9a1 100644 --- a/src/libecmabuiltins/ecma-builtin-typeerror.inc.h +++ b/src/libecmabuiltins/ecma-builtin-typeerror.inc.h @@ -49,7 +49,7 @@ NUMBER_VALUE (ECMA_MAGIC_STRING_LENGTH, /* Object properties: * (property name, object pointer getter) */ -// 15.7.3.1 +// 15.11.3.1 OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE, ecma_builtin_get (ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE), ECMA_PROPERTY_NOT_WRITABLE, diff --git a/src/libecmabuiltins/ecma-builtin-urierror-prototype.c b/src/libecmabuiltins/ecma-builtin-urierror-prototype.c new file mode 100644 index 000000000..f9141c2de --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-urierror-prototype.c @@ -0,0 +1,33 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ecma-alloc.h" +#include "ecma-builtins.h" +#include "ecma-conversion.h" +#include "ecma-exceptions.h" +#include "ecma-gc.h" +#include "ecma-globals.h" +#include "ecma-helpers.h" +#include "ecma-objects.h" +#include "ecma-string-object.h" +#include "ecma-try-catch-macro.h" +#include "globals.h" + +#define ECMA_BUILTINS_INTERNAL +#include "ecma-builtins-internal.h" + +#define BUILTIN_INC_HEADER_NAME "ecma-builtin-urierror-prototype.inc.h" +#define BUILTIN_UNDERSCORED_ID uri_error_prototype +#include "ecma-builtin-internal-routines-template.inc.h" diff --git a/src/libecmabuiltins/ecma-builtin-urierror-prototype.inc.h b/src/libecmabuiltins/ecma-builtin-urierror-prototype.inc.h new file mode 100644 index 000000000..6f0e1c238 --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-urierror-prototype.inc.h @@ -0,0 +1,65 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * UriError.prototype built-in description + */ + +#ifndef OBJECT_ID +# define OBJECT_ID(builtin_object_id) +#endif /* !OBJECT_ID */ + +#ifndef STRING_VALUE +# define STRING_VALUE(name, magic_string_id, prop_writable, prop_enumerable, prop_configurable) +#endif /* !STRING_VALUE */ + +#ifndef OBJECT_VALUE +# define OBJECT_VALUE(name, obj_getter, prop_writable, prop_enumerable, prop_configurable) +#endif /* !OBJECT_VALUE */ + +/* Object identifier */ +OBJECT_ID (ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE) + +/* Object properties: + * (property name, object pointer getter) */ + +// 15.11.7.8 +OBJECT_VALUE (ECMA_MAGIC_STRING_CONSTRUCTOR, + ecma_builtin_get (ECMA_BUILTIN_ID_URI_ERROR), + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) + +// 15.11.7.9 +STRING_VALUE (ECMA_MAGIC_STRING_NAME, + ECMA_MAGIC_STRING_URI_ERROR_UL, + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) + +// 15.11.7.10 +STRING_VALUE (ECMA_MAGIC_STRING_MESSAGE, + ECMA_MAGIC_STRING__EMPTY, + ECMA_PROPERTY_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_CONFIGURABLE) + +#undef OBJECT_ID +#undef SIMPLE_VALUE +#undef NUMBER_VALUE +#undef STRING_VALUE +#undef OBJECT_VALUE +#undef CP_UNIMPLEMENTED_VALUE +#undef ROUTINE diff --git a/src/libecmabuiltins/ecma-builtin-urierror.c b/src/libecmabuiltins/ecma-builtin-urierror.c new file mode 100644 index 000000000..7cafbc1e1 --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-urierror.c @@ -0,0 +1,97 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ecma-alloc.h" +#include "ecma-builtins.h" +#include "ecma-conversion.h" +#include "ecma-exceptions.h" +#include "ecma-gc.h" +#include "ecma-globals.h" +#include "ecma-helpers.h" +#include "ecma-objects.h" +#include "ecma-try-catch-macro.h" +#include "globals.h" + +#define ECMA_BUILTINS_INTERNAL +#include "ecma-builtins-internal.h" + +#define BUILTIN_INC_HEADER_NAME "ecma-builtin-urierror.inc.h" +#define BUILTIN_UNDERSCORED_ID uri_error +#include "ecma-builtin-internal-routines-template.inc.h" + +/** \addtogroup ecma ECMA + * @{ + * + * \addtogroup ecmabuiltins + * @{ + * + * \addtogroup urierror ECMA UriError object built-in + * @{ + */ + +/** + * Handle calling [[Call]] of built-in UriError object + * + * @return completion-value + */ +ecma_completion_value_t +ecma_builtin_uri_error_dispatch_call (ecma_value_t *arguments_list_p, /**< arguments list */ + ecma_length_t arguments_list_len) /**< number of arguments */ +{ + JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); + + if (arguments_list_len != 0 + && !ecma_is_value_undefined (arguments_list_p [0])) + { + ecma_completion_value_t ret_value; + + ECMA_TRY_CATCH (msg_to_str_completion, + ecma_op_to_string (arguments_list_p[0]), + ret_value); + + ecma_string_t *message_string_p = ECMA_GET_POINTER (msg_to_str_completion.u.value.value); + ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_URI, + message_string_p); + ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p)); + + ECMA_FINALIZE (msg_to_str_completion); + + return ret_value; + } + else + { + ecma_object_t *new_error_object_p = ecma_new_standard_error (ECMA_ERROR_URI); + + return ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p)); + } +} /* ecma_builtin_uri_error_dispatch_call */ + +/** + * Handle calling [[Construct]] of built-in UriError object + * + * @return completion-value + */ +ecma_completion_value_t +ecma_builtin_uri_error_dispatch_construct (ecma_value_t *arguments_list_p, /**< arguments list */ + ecma_length_t arguments_list_len) /**< number of arguments */ +{ + return ecma_builtin_uri_error_dispatch_call (arguments_list_p, arguments_list_len); +} /* ecma_builtin_uri_error_dispatch_construct */ + +/** + * @} + * @} + * @} + */ diff --git a/src/libecmabuiltins/ecma-builtin-urierror.inc.h b/src/libecmabuiltins/ecma-builtin-urierror.inc.h new file mode 100644 index 000000000..80125b19e --- /dev/null +++ b/src/libecmabuiltins/ecma-builtin-urierror.inc.h @@ -0,0 +1,65 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * UriError built-in description + */ + +#ifndef OBJECT_ID +# define OBJECT_ID(builtin_object_id) +#endif /* !OBJECT_ID */ + +#ifndef NUMBER_VALUE +# define NUMBER_VALUE(name, number_value, prop_writable, prop_enumerable, prop_configurable) +#endif /* !NUMBER_VALUE */ + +#ifndef STRING_VALUE +# define STRING_VALUE(name, magic_string_id, prop_writable, prop_enumerable, prop_configurable) +#endif /* !STRING_VALUE */ + +#ifndef OBJECT_VALUE +# define OBJECT_VALUE(name, obj_getter, prop_writable, prop_enumerable, prop_configurable) +#endif /* !OBJECT_VALUE */ + +/* Object identifier */ +OBJECT_ID (ECMA_BUILTIN_ID_URI_ERROR) + +/* Number properties: + * (property name, number value, writable, enumerable, configurable) */ + +// 15.11.3 +NUMBER_VALUE (ECMA_MAGIC_STRING_LENGTH, + 1, + ECMA_PROPERTY_NOT_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_NOT_CONFIGURABLE) + +/* Object properties: + * (property name, object pointer getter) */ + +// 15.11.3.1 +OBJECT_VALUE (ECMA_MAGIC_STRING_PROTOTYPE, + ecma_builtin_get (ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE), + ECMA_PROPERTY_NOT_WRITABLE, + ECMA_PROPERTY_NOT_ENUMERABLE, + ECMA_PROPERTY_NOT_CONFIGURABLE) + +#undef OBJECT_ID +#undef SIMPLE_VALUE +#undef NUMBER_VALUE +#undef STRING_VALUE +#undef OBJECT_VALUE +#undef CP_UNIMPLEMENTED_VALUE +#undef ROUTINE diff --git a/src/libecmabuiltins/ecma-builtins-internal.h b/src/libecmabuiltins/ecma-builtins-internal.h index c7b35e5e4..fe17d5ea2 100644 --- a/src/libecmabuiltins/ecma-builtins-internal.h +++ b/src/libecmabuiltins/ecma-builtins-internal.h @@ -135,26 +135,66 @@ ecma_builtin_bin_search_for_magic_string_id_in_array (const ecma_magic_string_id ERROR_UL, \ ECMA_BUILTIN_ID_ERROR_PROTOTYPE, \ error) \ - macro (TYPE_ERROR_PROTOTYPE, \ + macro (EVAL_ERROR_PROTOTYPE, \ TYPE_GENERAL, \ ERROR_UL, \ ECMA_BUILTIN_ID_ERROR_PROTOTYPE, \ - type_error_prototype) \ - macro (REFERENCE_ERROR, \ + eval_error_prototype) \ + macro (EVAL_ERROR, \ TYPE_FUNCTION, \ ERROR_UL, \ - ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE, \ - reference_error) \ + ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE, \ + eval_error) \ + macro (RANGE_ERROR_PROTOTYPE, \ + TYPE_GENERAL, \ + ERROR_UL, \ + ECMA_BUILTIN_ID_ERROR_PROTOTYPE, \ + range_error_prototype) \ + macro (RANGE_ERROR, \ + TYPE_FUNCTION, \ + ERROR_UL, \ + ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE, \ + range_error) \ macro (REFERENCE_ERROR_PROTOTYPE, \ TYPE_GENERAL, \ ERROR_UL, \ ECMA_BUILTIN_ID_ERROR_PROTOTYPE, \ reference_error_prototype) \ + macro (REFERENCE_ERROR, \ + TYPE_FUNCTION, \ + ERROR_UL, \ + ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE, \ + reference_error) \ + macro (SYNTAX_ERROR_PROTOTYPE, \ + TYPE_GENERAL, \ + ERROR_UL, \ + ECMA_BUILTIN_ID_ERROR_PROTOTYPE, \ + syntax_error_prototype) \ + macro (SYNTAX_ERROR, \ + TYPE_FUNCTION, \ + ERROR_UL, \ + ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE, \ + syntax_error) \ + macro (TYPE_ERROR_PROTOTYPE, \ + TYPE_GENERAL, \ + ERROR_UL, \ + ECMA_BUILTIN_ID_ERROR_PROTOTYPE, \ + type_error_prototype) \ macro (TYPE_ERROR, \ TYPE_FUNCTION, \ ERROR_UL, \ ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE, \ type_error) \ + macro (URI_ERROR_PROTOTYPE, \ + TYPE_GENERAL, \ + ERROR_UL, \ + ECMA_BUILTIN_ID_ERROR_PROTOTYPE, \ + uri_error_prototype) \ + macro (URI_ERROR, \ + TYPE_FUNCTION, \ + ERROR_UL, \ + ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE, \ + uri_error) \ macro (COMPACT_PROFILE_ERROR, \ TYPE_FUNCTION, \ COMPACT_PROFILE_ERROR_UL, \ diff --git a/src/libecmaoperations/ecma-exceptions.c b/src/libecmaoperations/ecma-exceptions.c index 9d7699cc1..28f978e2c 100644 --- a/src/libecmaoperations/ecma-exceptions.c +++ b/src/libecmaoperations/ecma-exceptions.c @@ -80,8 +80,8 @@ ecma_new_standard_error (ecma_standard_error_t error_type) /**< native error typ case ECMA_ERROR_SYNTAX: { - /* SyntaxError should be treated as an early error */ - JERRY_UNREACHABLE (); + prototype_id = ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE; + break; } } diff --git a/tests/jerry/error.js b/tests/jerry/error.js index c6d4a2cef..fe7a42919 100644 --- a/tests/jerry/error.js +++ b/tests/jerry/error.js @@ -110,3 +110,91 @@ catch (e) assert(!(e instanceof Function)); } + +/* EvalError */ +e = new EvalError (); +assert (e.name === "EvalError"); +assert (e.message === ""); +assert (e.toString() === "EvalError"); + +e = new EvalError("some message"); +assert (e.name === "EvalError"); +assert (e.message === "some message"); +assert (e.toString() === "EvalError: some message"); + +e.name = ""; +assert (e.toString() === "some message"); +e.message = ""; +assert (e.toString() === ""); + +assert (EvalError.prototype.toString === Error.prototype.toString); +assert (EvalError.prototype.constructor === EvalError); +assert (EvalError.prototype.name === "EvalError"); +assert (EvalError.prototype.message === ""); +assert (EvalError.prototype.toString() === "EvalError"); + +/* RangeError */ +e = new RangeError (); +assert (e.name === "RangeError"); +assert (e.message === ""); +assert (e.toString() === "RangeError"); + +e = new RangeError("some message"); +assert (e.name === "RangeError"); +assert (e.message === "some message"); +assert (e.toString() === "RangeError: some message"); + +e.name = ""; +assert (e.toString() === "some message"); +e.message = ""; +assert (e.toString() === ""); + +assert (RangeError.prototype.toString === Error.prototype.toString); +assert (RangeError.prototype.constructor === RangeError); +assert (RangeError.prototype.name === "RangeError"); +assert (RangeError.prototype.message === ""); +assert (RangeError.prototype.toString() === "RangeError"); + +/* SyntaxError */ +e = new SyntaxError (); +assert (e.name === "SyntaxError"); +assert (e.message === ""); +assert (e.toString() === "SyntaxError"); + +e = new SyntaxError("some message"); +assert (e.name === "SyntaxError"); +assert (e.message === "some message"); +assert (e.toString() === "SyntaxError: some message"); + +e.name = ""; +assert (e.toString() === "some message"); +e.message = ""; +assert (e.toString() === ""); + +assert (SyntaxError.prototype.toString === Error.prototype.toString); +assert (SyntaxError.prototype.constructor === SyntaxError); +assert (SyntaxError.prototype.name === "SyntaxError"); +assert (SyntaxError.prototype.message === ""); +assert (SyntaxError.prototype.toString() === "SyntaxError"); + +/* URIError */ +e = new URIError (); +assert (e.name === "URIError"); +assert (e.message === ""); +assert (e.toString() === "URIError"); + +e = new URIError("some message"); +assert (e.name === "URIError"); +assert (e.message === "some message"); +assert (e.toString() === "URIError: some message"); + +e.name = ""; +assert (e.toString() === "some message"); +e.message = ""; +assert (e.toString() === ""); + +assert (URIError.prototype.toString === Error.prototype.toString); +assert (URIError.prototype.constructor === URIError); +assert (URIError.prototype.name === "URIError"); +assert (URIError.prototype.message === ""); +assert (URIError.prototype.toString() === "URIError");