Throwing CompactProfileError in cases required by Compact Profile.

This commit is contained in:
Ruben Ayrapetyan
2014-10-16 21:25:25 +04:00
parent bd7fd40a32
commit e54023caf2
5 changed files with 180 additions and 1 deletions
+47
View File
@@ -72,6 +72,21 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
{
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
{
#ifdef CONFIG_ECMA_COMPACT_PROFILE
ecma_string_t *arguments_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_ARGUMENTS);
bool is_equal = false;
if (ecma_compare_ecma_strings (name_p, arguments_magic_string_p))
{
is_equal = true;
}
ecma_deref_ecma_string (arguments_magic_string_p);
if (is_equal)
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
}
#endif /* CONFIG_ECMA_COMPACT_PROFILE */
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
has_binding = (property_p != NULL) ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE;
@@ -194,6 +209,22 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment
{
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
{
#ifdef CONFIG_ECMA_COMPACT_PROFILE
bool is_equal = false;
ecma_string_t *arguments_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_ARGUMENTS);
if (ecma_compare_ecma_strings (name_p, arguments_magic_string_p))
{
is_equal = true;
}
ecma_deref_ecma_string (arguments_magic_string_p);
if (is_equal)
{
return ecma_make_throw_obj_completion_value (ecma_builtin_get (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR));
}
#endif /* CONFIG_ECMA_COMPACT_PROFILE */
ecma_property_t *property_p = ecma_get_named_data_property (lex_env_p, name_p);
if (property_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE)
@@ -255,6 +286,22 @@ ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */
{
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
{
#ifdef CONFIG_ECMA_COMPACT_PROFILE
bool is_equal = false;
ecma_string_t *arguments_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_ARGUMENTS);
if (ecma_compare_ecma_strings (name_p, arguments_magic_string_p))
{
is_equal = true;
}
ecma_deref_ecma_string (arguments_magic_string_p);
if (is_equal)
{
return ecma_make_throw_obj_completion_value (ecma_builtin_get (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR));
}
#endif /* CONFIG_ECMA_COMPACT_PROFILE */
ecma_property_t *property_p = ecma_get_named_data_property (lex_env_p, name_p);
ecma_value_t prop_value = property_p->u.named_data_property.value;