Exemplo n.º 1
0
void
scopes_tree_set_op_meta (scopes_tree tree, vm_instr_counter_t oc, op_meta op)
{
  assert_tree (tree);
  JERRY_ASSERT (oc < tree->instrs_count);
  linked_list_set_element (tree->instrs, oc, &op);
}
Exemplo n.º 2
0
/**
 * Add variable declaration to a scope
 */
void
scopes_tree_add_var_decl (scopes_tree tree, /**< scope, to which variable declaration is added */
                          op_meta op) /**< variable declaration instruction */
{
  assert_tree (tree);
  linked_list_set_element (tree->var_decls, tree->var_decls_cout++, &op);
} /* scopes_tree_add_var_decl */
Exemplo n.º 3
0
/**
 * Initialize a scope
 *
 * @return initialized scope
 */
scopes_tree
scopes_tree_init (scopes_tree parent) /**< parent scope */
{
  scopes_tree tree = (scopes_tree) jsp_mm_alloc (sizeof (scopes_tree_int));
  memset (tree, 0, sizeof (scopes_tree_int));
  tree->t.parent = (tree_header *) parent;
  tree->t.children = null_list;
  tree->t.children_num = 0;
  if (parent != NULL)
  {
    if (parent->t.children_num == 0)
    {
      parent->t.children = linked_list_init (sizeof (scopes_tree));
    }
    linked_list_set_element (parent->t.children, parent->t.children_num, &tree);
    void *added = linked_list_element (parent->t.children, parent->t.children_num);
    JERRY_ASSERT (*(scopes_tree *) added == tree);
    parent->t.children_num++;
  }
  tree->instrs_count = 0;
  tree->strict_mode = false;
  tree->ref_eval = false;
  tree->ref_arguments = false;
  tree->instrs = linked_list_init (sizeof (op_meta));
  tree->var_decls_cout = 0;
  tree->var_decls = linked_list_init (sizeof (op_meta));
  return tree;
} /* scopes_tree_init */
Exemplo n.º 4
0
void
linked_list_set_element (linked_list list, size_t element_num, void *element)
{
  ASSERT_LIST (list);
  linked_list_header *header = (linked_list_header *) list;
  size_t block_size = linked_list_block_size (header->element_size);
  uint8_t *raw = (uint8_t *) (header + 1);
  if (block_size < header->element_size * (element_num + 1))
  {
    if (header->next == null_list)
    {
      header->next = (linked_list_header *) linked_list_init (header->element_size);
    }
    linked_list_set_element ((linked_list) header->next,
                             element_num - (block_size / header->element_size),
                             element);
    return;
  }
  if (element == NULL)
  {
    return;
  }
  memcpy (raw + element_num * header->element_size, element, header->element_size);
}
Exemplo n.º 5
0
void
scopes_tree_add_op_meta (scopes_tree tree, op_meta op)
{
  assert_tree (tree);
  linked_list_set_element (tree->instrs, tree->instrs_count++, &op);
}