Пример #1
0
static PyObject *
sympy_get_symtab (PyObject *self, void *closure)
{
    struct symbol *symbol = NULL;

    SYMPY_REQUIRE_VALID (self, symbol);

    return symtab_to_symtab_object (SYMBOL_SYMTAB (symbol));
}
Пример #2
0
static PyObject *
sympy_get_symtab (PyObject *self, void *closure)
{
  struct symbol *symbol = NULL;

  SYMPY_REQUIRE_VALID (self, symbol);

  if (!SYMBOL_OBJFILE_OWNED (symbol))
    Py_RETURN_NONE;

  return symtab_to_symtab_object (symbol_symtab (symbol));
}
Пример #3
0
/* Given a sal, and a sal_object that has previously been allocated
   and initialized, populate the sal_object with the struct sal data.
   Also, register the sal_object life-cycle with the life-cycle of the
   object file associated with this sal, if needed.  If a failure
   occurs during the sal population, this function will return -1.  */
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
set_sal (sal_object *sal_obj, struct symtab_and_line sal)
{
  symtab_object *symtab_obj;

  if (sal.symtab)
    {
      symtab_obj = (symtab_object *) symtab_to_symtab_object  (sal.symtab);
      /* If a symtab existed in the sal, but it cannot be duplicated,
	 we exit.  */
      if (symtab_obj == NULL)
	return -1;
    }
  else
    {
      symtab_obj = (symtab_object *) Py_None;
      Py_INCREF (Py_None);
    }

  sal_obj->sal = ((struct symtab_and_line *)
		  xmemdup (&sal, sizeof (struct symtab_and_line),
			   sizeof (struct symtab_and_line)));
  sal_obj->symtab = symtab_obj;
  sal_obj->prev = NULL;

  /* If the SAL does not have a symtab, we do not add it to the
     objfile cleanup observer linked list.  */
  if (sal_obj->symtab != (symtab_object *)Py_None)
    {
      sal_obj->next
	= ((struct salpy_sal_object *)
	   objfile_data (SYMTAB_OBJFILE (sal_obj->symtab->symtab),
			 salpy_objfile_data_key));
      if (sal_obj->next)
	sal_obj->next->prev = sal_obj;

      set_objfile_data (SYMTAB_OBJFILE (sal_obj->symtab->symtab),
			salpy_objfile_data_key, sal_obj);
    }
  else
    sal_obj->next = NULL;

  return 0;
}
Пример #4
0
/* Given a sal, and a sal_object that has previously been allocated
   and initialized, populate the sal_object with the struct sal data.
   Also, register the sal_object life-cycle with the life-cycle of the
   object file associated with this sal, if needed.  If a failure
   occurs during the sal population, this function will return
   NULL.  */
static int
set_sal (sal_object *sal_obj, struct symtab_and_line sal)
{
    symtab_object *symtab_obj;

    if (sal.symtab)
    {
        symtab_obj = (symtab_object *) symtab_to_symtab_object  (sal.symtab);
        /* If a symtab existed in the sal, but it cannot be duplicated,
        we exit.  */
        if (symtab_obj == NULL)
            return 0;
    }
    else
    {
        symtab_obj = (symtab_object *) Py_None;
        Py_INCREF (Py_None);
    }

    sal_obj->sal = xmemdup (&sal, sizeof (struct symtab_and_line),
                            sizeof (struct symtab_and_line));
    sal_obj->symtab = symtab_obj;
    sal_obj->prev = NULL;

    /* If the SAL does not have a symtab, we do not add it to the
       objfile cleanup observer linked list.  */
    if (sal_obj->symtab != (symtab_object *)Py_None)
    {
        sal_obj->next = objfile_data (sal_obj->symtab->symtab->objfile,
                                      salpy_objfile_data_key);
        if (sal_obj->next)
            sal_obj->next->prev = sal_obj;

        set_objfile_data (sal_obj->symtab->symtab->objfile,
                          salpy_objfile_data_key, sal_obj);
    }
    else
        sal_obj->next = NULL;

    return 1;
}