Пример #1
0
/* 13.1, 15.3.2 */
void
syntax_check_for_syntax_errors_in_formal_param_list (bool is_strict, locus loc __attr_unused___)
{
  if (STACK_SIZE (props) - STACK_TOP (U8) < 2 || !is_strict)
  {
    STACK_DROP (U8, 1);
    return;
  }
  for (uint8_t i = (uint8_t) (STACK_TOP (U8) + 1); i < STACK_SIZE (props); i = (uint8_t) (i + 1))
  {
    JERRY_ASSERT (STACK_ELEMENT (props, i).type == VARG);
    literal_t previous = STACK_ELEMENT (props, i).lit;
    JERRY_ASSERT (previous->get_type () == LIT_STR_T
                  || previous->get_type () == LIT_MAGIC_STR_T
                  || previous->get_type () == LIT_MAGIC_STR_EX_T);
    for (uint8_t j = STACK_TOP (U8); j < i; j = (uint8_t) (j + 1))
    {
      JERRY_ASSERT (STACK_ELEMENT (props, j).type == VARG);
      literal_t current = STACK_ELEMENT (props, j).lit;
      JERRY_ASSERT (current->get_type () == LIT_STR_T
                    || current->get_type () == LIT_MAGIC_STR_T
                    || current->get_type () == LIT_MAGIC_STR_EX_T);
      if (lit_literal_equal_type (previous, current))
      {
        PARSE_ERROR_VARG ("Duplication of literal '%s' in FormalParameterList is not allowed in strict mode",
                          loc, lit_literal_to_str_internal_buf (previous));
      }
    }
  }

  STACK_DROP (props, (uint8_t) (STACK_SIZE (props) - STACK_TOP (U8)));
  STACK_DROP (U8, 1);
}
Пример #2
0
/* 13.1, 15.3.2 */
void
jsp_early_error_check_for_syntax_errors_in_formal_param_list (bool is_strict, locus loc __attr_unused___)
{
  if (is_strict
      && STACK_SIZE (props) - STACK_TOP (size_t_stack) >= 2)
  {
    for (size_t i = (STACK_TOP (size_t_stack) + 1u); i < STACK_SIZE (props); i++)
    {
      JERRY_ASSERT (STACK_ELEMENT (props, i).type == VARG);
      literal_t previous = STACK_ELEMENT (props, i).lit;
      JERRY_ASSERT (previous->get_type () == LIT_STR_T
                    || previous->get_type () == LIT_MAGIC_STR_T
                    || previous->get_type () == LIT_MAGIC_STR_EX_T);
      for (size_t j = STACK_TOP (size_t_stack); j < i; j++)
      {
        JERRY_ASSERT (STACK_ELEMENT (props, j).type == VARG);
        literal_t current = STACK_ELEMENT (props, j).lit;
        JERRY_ASSERT (current->get_type () == LIT_STR_T
                      || current->get_type () == LIT_MAGIC_STR_T
                      || current->get_type () == LIT_MAGIC_STR_EX_T);
        if (lit_literal_equal_type (previous, current))
        {
          PARSE_ERROR_VARG (JSP_EARLY_ERROR_SYNTAX,
                            "Duplication of literal '%s' in FormalParameterList is not allowed in strict mode",
                            loc, lit_literal_to_str_internal_buf (previous));
        }
      }
    }
  }

  STACK_DROP (props, (size_t) (STACK_SIZE (props) - STACK_TOP (size_t_stack)));
  STACK_DROP (size_t_stack, 1);
}
Пример #3
0
void
syntax_check_for_duplication_of_prop_names (bool is_strict, locus loc __attr_unused___)
{
  if (STACK_SIZE (props) - STACK_TOP (U8) < 2)
  {
    STACK_DROP (U8, 1);
    return;
  }

  for (uint8_t i = (uint8_t) (STACK_TOP (U8) + 1);
       i < STACK_SIZE (props);
       i++)
  {
    const prop_literal previous = STACK_ELEMENT (props, i);
    if (previous.type == VARG)
    {
      continue;
    }
    JERRY_ASSERT (previous.type == PROP_DATA
                  || previous.type == PROP_GET
                  || previous.type == PROP_SET);
    for (uint8_t j = STACK_TOP (U8); j < i; j = (uint8_t) (j + 1))
    {
      /*4*/
      const prop_literal current = STACK_ELEMENT (props, j);
      if (current.type == VARG)
      {
        continue;
      }
      JERRY_ASSERT (current.type == PROP_DATA
                    || current.type == PROP_GET
                    || current.type == PROP_SET);
      if (lit_literal_equal (previous.lit, current.lit))
      {
        /*a*/
        if (is_strict && previous.type == PROP_DATA && current.type == PROP_DATA)
        {
          PARSE_ERROR_VARG ("Duplication of parameter name '%s' in ObjectDeclaration is not allowed in strict mode",
                            loc, lit_literal_to_str_internal_buf (current.lit));
        }
        /*b*/
        if (previous.type == PROP_DATA
            && (current.type == PROP_SET || current.type == PROP_GET))
        {
          PARSE_ERROR_VARG ("Parameter name '%s' in ObjectDeclaration may not be both data and accessor",
                            loc, lit_literal_to_str_internal_buf (current.lit));
        }
        /*c*/
        if (current.type == PROP_DATA
            && (previous.type == PROP_SET || previous.type == PROP_GET))
        {
          PARSE_ERROR_VARG ("Parameter name '%s' in ObjectDeclaration may not be both data and accessor",
                            loc, lit_literal_to_str_internal_buf (current.lit));
        }
        /*d*/
        if ((previous.type == PROP_SET && current.type == PROP_SET)
            || (previous.type == PROP_GET && current.type == PROP_GET))
        {
          PARSE_ERROR_VARG ("Parameter name '%s' in ObjectDeclaration may not be accessor of same type",
                            loc, lit_literal_to_str_internal_buf (current.lit));
        }
      }
    }
  }

  STACK_DROP (props, (uint8_t) (STACK_SIZE (props) - STACK_TOP (U8)));
  STACK_DROP (U8, 1);
}