Пример #1
0
CFUN__PROTO(current_instance, instance_t *)
{
  int_info_t *root;
  BlockingType block;
#if defined(PROFILE)
  tagged_t *junk;
  w->node->functor=find_definition(predicates_location,X(0),&junk,FALSE);
#endif
  PredTrace("I",w->node->functor);
  root =  TagToRoot(X(2));
  if (root->behavior_on_failure == DYNAMIC)
    return current_instance_noconc(Arg);
  else {
    DEREF(X(4), X(4));                                   /* Blocking? (MCL) */
#if defined(DEBUG)
    if (X(4) == atom_block)
      block = BLOCK;
    else if (X(4) == atom_no_block)
      block = NO_BLOCK;
    else {
      failc("$current_instance called with unkown 5th argument");
      return NULL;                         
    }
#else
    block = X(4) == atom_block ? BLOCK : NO_BLOCK;
#endif
    return current_instance_conc(Arg, block);
  }
}
Пример #2
0
/* If NAME already has a definition in scope at LINE in SOURCE, return
   the key.  If the old definition is different from the definition
   given by KIND, ARGC, ARGV, and REPLACEMENT, complain, too.
   Otherwise, return zero.  (ARGC and ARGV are meaningless unless KIND
   is `macro_function_like'.)  */
static struct macro_key *
check_for_redefinition (struct macro_source_file *source, int line,
                        const char *name, enum macro_kind kind,
                        int argc, const char **argv,
                        const char *replacement)
{
  splay_tree_node n = find_definition (name, source, line);

  if (n)
    {
      struct macro_key *found_key = (struct macro_key *) n->key;
      struct macro_definition *found_def
        = (struct macro_definition *) n->value;
      int same = 1;

      /* Is this definition the same as the existing one?
         According to the standard, this comparison needs to be done
         on lists of tokens, not byte-by-byte, as we do here.  But
         that's too hard for us at the moment, and comparing
         byte-by-byte will only yield false negatives (i.e., extra
         warning messages), not false positives (i.e., unnoticed
         definition changes).  */
      if (kind != found_def->kind)
        same = 0;
      else if (strcmp (replacement, found_def->replacement))
        same = 0;
      else if (kind == macro_function_like)
        {
          if (argc != found_def->argc)
            same = 0;
          else
            {
              int i;

              for (i = 0; i < argc; i++)
                if (strcmp (argv[i], found_def->argv[i]))
                  same = 0;
            }
        }

      if (! same)
        {
	  char *source_fullname, *found_key_fullname;
	  
	  source_fullname = macro_source_fullname (source);
	  found_key_fullname = macro_source_fullname (found_key->start_file);
	  complaint (&symfile_complaints,
		     _("macro `%s' redefined at %s:%d; "
		       "original definition at %s:%d"),
		     name, source_fullname, line, found_key_fullname,
		     found_key->start_line);
	  xfree (found_key_fullname);
	  xfree (source_fullname);
        }

      return found_key;
    }
  else
    return 0;
}
Пример #3
0
int timecoder_init(struct timecoder_t *tc, const char *def_name,
		   unsigned int sample_rate)
{
    /* A definition contains a lookup table which can be shared
     * across multiple timecoders */

    tc->def = find_definition(def_name);
    if (tc->def == NULL) {
        fprintf(stderr, "Timecode definition '%s' is not known.\n", def_name);
        return -1;
    }
    if (build_lookup(tc->def) == -1)
        return -1;

    tc->dt = 1.0 / sample_rate;
    tc->zero_alpha = tc->dt / (ZERO_RC + tc->dt);

    tc->forwards = 1;
    init_channel(&tc->primary);
    init_channel(&tc->secondary);
    pitch_init(&tc->pitch, tc->dt);

    tc->ref_level = 32768.0;
    tc->bitstream = 0;
    tc->timecode = 0;
    tc->valid_counter = 0;
    tc->timecode_ticker = 0;

    tc->mon = NULL;

    return 0;
}
Пример #4
0
void
macro_undef (struct macro_source_file *source, int line,
             const char *name)
{
  splay_tree_node n = find_definition (name, source, line);

  if (n)
    {
      struct macro_key *key = (struct macro_key *) n->key;

      /* If we're removing a definition at exactly the same point that
         we defined it, then just delete the entry altogether.  GCC
         4.1.2 will generate DWARF that says to do this if you pass it
         arguments like '-DFOO -UFOO -DFOO=2'.  */
      if (source == key->start_file
          && line == key->start_line)
        splay_tree_remove (source->table->definitions, n->key);

      else
        {
          /* This function is the only place a macro's end-of-scope
             location gets set to anything other than "end of the
             compilation unit" (i.e., end_file is zero).  So if this
             macro already has its end-of-scope set, then we're
             probably seeing a second #undefinition for the same
             #definition.  */
          if (key->end_file)
            {
	      char *source_fullname, *key_fullname;

	      source_fullname = macro_source_fullname (source);
	      key_fullname = macro_source_fullname (key->end_file);
              complaint (&symfile_complaints,
                         _("macro '%s' is #undefined twice,"
                           " at %s:%d and %s:%d"),
			 name, source_fullname, line, key_fullname,
			 key->end_line);
	      xfree (key_fullname);
	      xfree (source_fullname);
            }

          /* Whether or not we've seen a prior #undefinition, wipe out
             the old ending point, and make this the ending point.  */
          key->end_file = source;
          key->end_line = line;
        }
    }
  else
    {
      /* According to the ISO C standard, an #undef for a symbol that
         has no macro definition in scope is ignored.  So we should
         ignore it too.  */
#if 0
      complaint (&symfile_complaints,
		 _("no definition for macro `%s' in scope to #undef at %s:%d"),
		 name, source->filename, line);
#endif
    }
}
void set_definition_of_block( basic_block_t *ptr_block)
{
	quadruple_t * head = ptr_block->head;
	while(head)
	{
		strcpy(  head->def , find_definition( head->inst ) );
	  	head = head->link;
	}
}
Пример #6
0
NCURSES_SP_NAME(key_defined) (NCURSES_SP_DCLx const char *str)
{
    int code = ERR;

    T((T_CALLED("key_defined(%p, %s)"), (void *) SP_PARM, _nc_visbuf(str)));
    if (SP_PARM != 0 && str != 0) {
	code = find_definition(SP_PARM->_keytry, str);
    }

    returnCode(code);
}
Пример #7
0
key_defined(const char *str)
{
    int code = ERR;

    T((T_CALLED("key_defined(%s)"), _nc_visbuf(str)));
    if (SP != 0 && str != 0) {
	code = find_definition(SP->_keytry, str);
    }

    returnCode(code);
}
Пример #8
0
struct macro_source_file *
macro_definition_location (struct macro_source_file *source,
                           int line,
                           const char *name,
                           int *definition_line)
{
  splay_tree_node n = find_definition (name, source, line);

  if (n)
    {
      struct macro_key *key = (struct macro_key *) n->key;

      *definition_line = key->start_line;
      return key->start_file;
    }
  else
    return 0;
}
Пример #9
0
struct macro_definition *
macro_lookup_definition (struct macro_source_file *source,
                         int line, const char *name)
{
  splay_tree_node n = find_definition (name, source, line);

  if (n)
    {
      struct macro_definition *retval;
      char *source_fullname;

      source_fullname = macro_source_fullname (source);
      retval = fixup_definition (source_fullname, line,
				 (struct macro_definition *) n->value);
      xfree (source_fullname);
      return retval;
    }
  else
    return 0;
}
Пример #10
0
static int
find_definition(struct tries *tree, const char *str)
{
    struct tries *ptr;
    int result = 0;

    if (str != 0 && *str != '\0') {
	for (ptr = tree; ptr != 0; ptr = ptr->sibling) {
	    if (UChar(*str) == UChar(ptr->ch)) {
		if (str[1] == '\0' && ptr->child != 0) {
		    result = -1;
		} else if ((result = find_definition(ptr->child, str + 1)) == 0) {
		    result = ptr->value;
		} else if (str[1] == '\0') {
		    result = -1;
		}
	    }
	    if (result != 0)
		break;
	}
    }
    return (result);
}