Esempio n. 1
0
/*
 * deep_inventory()
 *
 * This function returns the recursive inventory of an object. The returned 
 * array of objects is flat, ie there is no structure reflecting the 
 * internal containment relations.
 *
 */
struct vector *
deep_inventory(struct object *ob, int take_top)
{
    struct vector	*dinv, *ainv, *sinv, *tinv;
    int			il;

    ainv = all_inventory(ob);
    if (take_top)
    {
	sinv = allocate_array(1);
	sinv->item[0].type = T_OBJECT;
	add_ref(ob,"deep_inventory");
	sinv->item[0].u.ob = ob;
	dinv = add_array(sinv, ainv);
	free_vector(sinv);
	free_vector(ainv);
	ainv = dinv;
    }
    sinv = ainv;
    for (il = take_top ? 1 : 0 ; il < ainv->size ; il++)
    {
	if (ainv->item[il].u.ob->contains)
	{
	    dinv = deep_inventory(ainv->item[il].u.ob,0);
	    tinv = add_array(sinv, dinv);
	    if (sinv != ainv)
		free_vector(sinv);
	    sinv = tinv;
	    free_vector(dinv);
	}
    }
    if (ainv != sinv)
	free_vector(ainv);
    return sinv;
}
Esempio n. 2
0
main()
{
	int len,*arr1,*arr2,*add_arr,i;

	printf("enter the size of the 2 arrays");
	scanf("%d",&len);
	arr1=(int *)malloc(len*sizeof(int));
	arr2=(int *)malloc(len*sizeof(int));
	printf("enter 1st array elements");
	for(i=0;i<len;i++)
	{
		scanf("%d",arr1+i);
	}
	printf("enter 2nd array elements");
	for(i=0;i<len;i++)
	{
		scanf("%d",arr2+i);
	}

	add_arr=add_array(len,arr1,arr2);
	printf("the resultant array is ");
	for(i=0;i<len;i++)
	{
		printf("%3d",*(add_arr+i));
	}
	getch();

}
Esempio n. 3
0
static void task_sum_work( void * arg , TPI_ThreadPool pool )
{
    int p_size , p_rank ;

    if ( ! TPI_Rank( pool , & p_rank , & p_size ) ) {

        struct TaskX * const t  = (struct TaskX *) arg ;

        const unsigned p_next = p_rank + 1 ;
        const unsigned n = t->number ;
        const double * const xb = t->x_beg + ( n * p_rank ) / p_size ;
        const double * const xe = t->x_beg + ( n * p_next ) / p_size ;
        double * const v  = t->x_sum ;

        double partial[4] = { 0 , 0 , 0 , 0 };

        add_array( partial , xb , xe );

        TPI_Lock( pool , 0 );

        xdsum_add_dsum( v , partial );

        TPI_Unlock( pool , 0 );
    }
}
Esempio n. 4
0
static double multigrid_recurse(struct element **sel, double ****f,
		double ****x, int var, int level, double eps,
		void (*opeval) ())
{
	if (level == (*sel)->precon->nlevels - 1)
		return conjugate_gradient(sel, f, x, var, opeval,
				jacobi_preconditioner, eps, 500);

	const int m = 15;
	const int n1 = (*sel)->basis->n;
	const int n2 = (*sel)->precon->nmg[level + 1];
	double ****r = new_4d_array(n1, n1, n1, (*sel)->nel);
	double ****fn = new_4d_array(n2, n2, n2, (*sel)->nel);
	double ****e = new_4d_array(n2, n2, n2, (*sel)->nel);

	if (level == 0)
		compute_residual(sel, x, f, r, var, opeval);
	else
		copy_array(***f, ***r, n1 * n1 * n1 * (*sel)->nel);

	switch_multigrid_level(sel, level + 1);
	multigrid_restriction(sel, r, fn, level + 1);
	multigrid_recurse(sel, fn, e, var, level + 1, eps, opeval);
	switch_multigrid_level(sel, level);
	multigrid_prolongation(sel, e, r, level);
	add_array(***r, ***x, n1 * n1 * n1 * (*sel)->nel, 1.0);

	double err = conjugate_gradient(sel, f, x, var, opeval,
			jacobi_preconditioner, eps, m);
	free_4d_array(r);
	free_4d_array(fn);
	free_4d_array(e);
	return err;
}
Esempio n. 5
0
static void compute_residual(struct element **sel, double ****x, double ****f,
	double ****r, int var, void (*opeval) ())
{
	const int n = (*sel)->basis->ntot;
	global_opeval(sel, x, r, var, opeval);
	scale_array(***r, n * (*sel)->nel, -1.0);
	add_array(***f, ***r, n * (*sel)->nel, 1.0);
}
Esempio n. 6
0
int main (){
    int sum;

    verify_array(48);
    sum = add_array(48);
    verify_array(48);

    Exit(sum);
}
Esempio n. 7
0
void testAdd() {
	printf("=== Test add ===\n");
	uint32_t a[] = { 0x01234567, 0x89abcdef };
	uint32_t b[] = { 0x12000002, 0x77000001 };
	uint32_t c[2];
	add_array(2, a, b, c);
	uint32_t expected[] = { 0x1323456a, 0x00abcdf0 };
	assertArrayEquals(2, expected, c);
}
int main(int argc, char **argv) {
  int *a, *b;
  int n = 3;
  a = malloc(sizeof(int) * 3);
  b = malloc(sizeof(int) * 3);
  int i, sum;
  for (i = 0; i < n; i++) {
    a[i] = i;
    b[i] = i;
  }
  sum = add_array(a, b, 3);
  printf("The addition is %d\n", sum);
  return 0;
}
Esempio n. 9
0
static void
read_snmp_conf(const char *address)	/* I - Single address to probe */
{
  cups_file_t	*fp;			/* File pointer */
  char		filename[1024],		/* Filename */
		line[1024],		/* Line from file */
		*value;			/* Value on line */
  int		linenum;		/* Line number */
  const char	*cups_serverroot;	/* CUPS_SERVERROOT env var */
  const char	*debug;			/* CUPS_DEBUG_LEVEL env var */
  const char	*runtime;		/* CUPS_MAX_RUN_TIME env var */


 /*
  * Initialize the global address and community lists...
  */

  Addresses   = cupsArrayNew(NULL, NULL);
  Communities = cupsArrayNew(NULL, NULL);

  if (address)
    add_array(Addresses, address);

  if ((debug = getenv("CUPS_DEBUG_LEVEL")) != NULL)
    DebugLevel = atoi(debug);

  if ((runtime = getenv("CUPS_MAX_RUN_TIME")) != NULL)
    MaxRunTime = atoi(runtime);

 /*
  * Find the snmp.conf file...
  */

  if ((cups_serverroot = getenv("CUPS_SERVERROOT")) == NULL)
    cups_serverroot = CUPS_SERVERROOT;

  snprintf(filename, sizeof(filename), "%s/snmp.conf", cups_serverroot);

  if ((fp = cupsFileOpen(filename, "r")) != NULL)
  {
   /*
    * Read the snmp.conf file...
    */

    linenum = 0;

    while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum))
    {
      if (!value)
        fprintf(stderr, "ERROR: Missing value on line %d of %s!\n", linenum,
	        filename);
      else if (!_cups_strcasecmp(line, "Address"))
      {
        if (!address)
          add_array(Addresses, value);
      }
      else if (!_cups_strcasecmp(line, "Community"))
        add_array(Communities, value);
      else if (!_cups_strcasecmp(line, "DebugLevel"))
        DebugLevel = atoi(value);
      else if (!_cups_strcasecmp(line, "DeviceURI"))
      {
        if (*value != '\"')
	  fprintf(stderr,
	          "ERROR: Missing double quote for regular expression on "
		  "line %d of %s!\n", linenum, filename);
        else
	  add_device_uri(value);
      }
      else if (!_cups_strcasecmp(line, "HostNameLookups"))
        HostNameLookups = !_cups_strcasecmp(value, "on") ||
	                  !_cups_strcasecmp(value, "yes") ||
	                  !_cups_strcasecmp(value, "true") ||
	                  !_cups_strcasecmp(value, "double");
      else if (!_cups_strcasecmp(line, "MaxRunTime"))
        MaxRunTime = atoi(value);
      else
        fprintf(stderr, "ERROR: Unknown directive %s on line %d of %s!\n",
	        line, linenum, filename);
    }

    cupsFileClose(fp);
  }

 /*
  * Use defaults if parameters are undefined...
  */

  if (cupsArrayCount(Addresses) == 0)
  {
   /*
    * If we have no addresses, exit immediately...
    */

    fprintf(stderr,
            "DEBUG: No address specified and no Address line in %s...\n",
	    filename);
    exit(0);
  }

  if (cupsArrayCount(Communities) == 0)
  {
    fputs("INFO: Using default SNMP Community public\n", stderr);
    add_array(Communities, "public");
  }
}
Esempio n. 10
0
void c_add_eq(int  is_void) {
    DEBUG_CHECK(sp->type != T_LVALUE,
		"non-lvalue argument to +=\n");
    lval = sp->u.lvalue;
    sp--; /* points to the RHS */
    switch (lval->type) {
    case T_STRING:
	if (sp->type == T_STRING) {
	    SVALUE_STRING_JOIN(lval, sp, "f_add_eq: 1");
	} else if (sp->type == T_NUMBER) {
	    char buff[20];
	    
	    sprintf(buff, "%d", sp->u.number);
	    EXTEND_SVALUE_STRING(lval, buff, "f_add_eq: 2");
	} else if (sp->type == T_REAL) {
	    char buff[40];
	    
	    sprintf(buff, "%f", sp->u.real);
	    EXTEND_SVALUE_STRING(lval, buff, "f_add_eq: 2");
	} else {
	    bad_argument(sp, T_STRING | T_NUMBER | T_REAL, 2,
			 (is_void ? F_VOID_ADD_EQ : F_ADD_EQ));
	}
	break;
    case T_NUMBER:
	if (sp->type == T_NUMBER) {
	    lval->u.number += sp->u.number;
	    /* both sides are numbers, no freeing required */
	} else if (sp->type == T_REAL) {
	    lval->u.number += sp->u.real;
	    /* both sides are numbers, no freeing required */
	} else {
	    error("Left hand side of += is a number (or zero); right side is not a number.\n");
	}
	break;
    case T_REAL:
	if (sp->type == T_NUMBER) {
	    lval->u.real += sp->u.number;
	    /* both sides are numerics, no freeing required */
	}
	if (sp->type == T_REAL) {
	    lval->u.real += sp->u.real;
	    /* both sides are numerics, no freeing required */
	} else {
	    error("Left hand side of += is a number (or zero); right side is not a number.\n");
	}
	break;
#ifndef NO_BUFFER_TYPE
    case T_BUFFER:
	if (sp->type != T_BUFFER) {
	    bad_argument(sp, T_BUFFER, 2, (is_void ? F_VOID_ADD_EQ : F_ADD_EQ));
	} else {
	    buffer_t *b;
	    
	    b = allocate_buffer(lval->u.buf->size + sp->u.buf->size);
	    memcpy(b->item, lval->u.buf->item, lval->u.buf->size);
	    memcpy(b->item + lval->u.buf->size, sp->u.buf->item,
		   sp->u.buf->size);
	    free_buffer(sp->u.buf);
	    free_buffer(lval->u.buf);
	    lval->u.buf = b;
	}
	break;
#endif
    case T_ARRAY:
	if (sp->type != T_ARRAY)
	    bad_argument(sp, T_ARRAY, 2, (is_void ? F_VOID_ADD_EQ : F_ADD_EQ));
	else {
	    /* add_array now frees the arrays */
	    lval->u.arr = add_array(lval->u.arr, sp->u.arr);
	}
	break;
    case T_MAPPING:
	if (sp->type != T_MAPPING)
	    bad_argument(sp, T_MAPPING, 2, (is_void ? F_VOID_ADD_EQ : F_ADD_EQ));
	else {
	    absorb_mapping(lval->u.map, sp->u.map);
	    free_mapping(sp->u.map);	/* free RHS */
	    /* LHS not freed because its being reused */
	}
	break;
    case T_LVALUE_BYTE:
	if (sp->type != T_NUMBER)
	    error("Bad right type to += of char lvalue.\n");
	else *global_lvalue_byte.u.lvalue_byte += sp->u.number;
	break;
    default:
	bad_arg(1, (is_void ? F_VOID_ADD_EQ : F_ADD_EQ));
    }
    
    if (!is_void) {	/* not void add_eq */
	assign_svalue_no_free(sp, lval);
    } else {
	/*
	 * but if (void)add_eq then no need to produce an
	 * rvalue
	 */
	sp--;
    }
}
Esempio n. 11
0
void c_add() {
    switch (sp->type) {
#ifndef NO_BUFFER_TYPE
    case T_BUFFER:
	{
	    if (!((sp-1)->type == T_BUFFER)) {
		error("Bad type argument to +. Had %s and %s.\n",
		      type_name((sp - 1)->type), type_name(sp->type));
	    } else {
		buffer_t *b;
		
		b = allocate_buffer(sp->u.buf->size + (sp - 1)->u.buf->size);
		memcpy(b->item, (sp - 1)->u.buf->item, (sp - 1)->u.buf->size);
		memcpy(b->item + (sp - 1)->u.buf->size, sp->u.buf->item,
		       sp->u.buf->size);
		free_buffer((sp--)->u.buf);
		free_buffer(sp->u.buf);
		sp->u.buf = b;
	    }
	    break;
	} /* end of x + T_BUFFER */
#endif
    case T_NUMBER:
	{
	    switch ((--sp)->type) {
	    case T_NUMBER:
		sp->u.number += (sp+1)->u.number;
		break;
	    case T_REAL:
		sp->u.real += (sp+1)->u.number;
		break;
	    case T_STRING:
		{
		    char buff[20];
		    
		    sprintf(buff, "%d", (sp+1)->u.number);
		    EXTEND_SVALUE_STRING(sp, buff, "f_add: 2");
		    break;
		}
	    default:
		error("Bad type argument to +.  Had %s and %s.\n",
		      type_name(sp->type), type_name((sp+1)->type));
	    }
	    break;
	} /* end of x + NUMBER */
    case T_REAL:
	{
	    switch ((--sp)->type) {
	    case T_NUMBER:
		sp->type = T_REAL;
		sp->u.real = sp->u.number + (sp+1)->u.real;
		break;
	    case T_REAL:
		sp->u.real += (sp+1)->u.real;
		break;
	    case T_STRING:
		{
		    char buff[40];
		    
		    sprintf(buff, "%f", (sp+1)->u.real);
		    EXTEND_SVALUE_STRING(sp, buff, "f_add: 2");
		    break;
		}
	    default:
		error("Bad type argument to +. Had %s and %s\n",
		      type_name(sp->type), type_name((sp+1)->type));
	    }
	    break;
	} /* end of x + T_REAL */
    case T_ARRAY:
	{
	    if (!((sp-1)->type == T_ARRAY)) {
		error("Bad type argument to +. Had %s and %s\n",
		      type_name((sp - 1)->type), type_name(sp->type));
	    } else {
		/* add_array now free's the arrays */
		(sp-1)->u.arr = add_array((sp - 1)->u.arr, sp->u.arr);
		sp--;
		break;
	    }
	} /* end of x + T_ARRAY */
    case T_MAPPING:
	{
	    if ((sp-1)->type == T_MAPPING) {
		mapping_t *map;
		
		map = add_mapping((sp - 1)->u.map, sp->u.map);
		free_mapping((sp--)->u.map);
		free_mapping(sp->u.map);
		sp->u.map = map;
		break;
	    } else
		error("Bad type argument to +. Had %s and %s\n",
		      type_name((sp - 1)->type), type_name(sp->type));
	} /* end of x + T_MAPPING */
    case T_STRING:
	{
	    switch ((sp-1)->type) {
	    case T_NUMBER:
		{
		    char buff[20];
		    
		    sprintf(buff, "%d", (sp-1)->u.number);
		    SVALUE_STRING_ADD_LEFT(buff, "f_add: 3");
		    break;
		} /* end of T_NUMBER + T_STRING */
	    case T_REAL:
		{
		    char buff[40];
		    
		    sprintf(buff, "%f", (sp - 1)->u.real);
		    SVALUE_STRING_ADD_LEFT(buff, "f_add: 3");
		    break;
		} /* end of T_REAL + T_STRING */
	    case T_STRING:
		{
		    SVALUE_STRING_JOIN(sp-1, sp, "f_add: 1");
		    sp--;
		    break;
		} /* end of T_STRING + T_STRING */
	    default:
		error("Bad type argument to +. Had %s and %s\n",
		      type_name((sp - 1)->type), type_name(sp->type));
	    }
	    break;
	} /* end of x + T_STRING */
	
    default:
	error("Bad type argument to +.  Had %s and %s.\n",
	      type_name((sp-1)->type), type_name(sp->type));
    }
}
Esempio n. 12
0
/**
 * ファイルを読み込んでドキュメントと転置索引を作る関数
 * @param char *file_name 開くファイル名
 */
void read_file(char *file_name)
{
    FILE *fp;
    int c;
    int pre_word_id = -1, cur_word_id;   // 単語のID
    char *word; // 現在の単語
    char *line; // 現在の行
    int word_len = 0;   // 単語の現在の文字数
    int line_len = 0;   // 行の現在の文字数
    int word_len_max = WORD_LENGTH_UNIT;    // 単語の文字数の初期単位
    int line_len_max = LINE_LENGTH_UNIT;    // 行の文字数の初期単位
    STATE state = S_SPACE;    // 状態
    
    if ((fp = fopen(file_name, "r")) == NULL)
    {
        fprintf(stderr, "File Open Error: %s\n", file_name);
        exit(1);
    }
    
    // ある程度の大きさで確保
    word = (char *)malloc(sizeof(char) * word_len_max);
    line = (char *)malloc(sizeof(char) * line_len_max);
    
    if (word == NULL || line == NULL)
    {
        printf("Memory Allocation Error\n");
        exit(1);
    }
    
    // 終わりまで1文字ずつ取得
    while (1)
    {
        c = getc(fp);   // 文字の取得
        
        // 空白文字か判別
        if (isspace(c) || c == EOF)
        {
            if (state == S_WORD)    // 文字が入力されていたなら
            {
                // 単語にNULL文字を追加
                set_character(&word, '\0', &word_len, &word_len_max);
                cur_word_id = add_array(word, n_docs);    // 配列に追加
                if (pre_word_id != -1)  // 前回の単語がある場合
                    associate_words(pre_word_id, cur_word_id, n_docs); // 関連付け

                word_len = 0;               // 単語の文字数の初期化
                pre_word_id = cur_word_id;  // 前回の単語のIDを保存
            }
            
            if (c == '\n' || c == '\r' || c == EOF)  // 改行かファイルの終わりなら
            {
                // 行にNULL文字を追加
                set_character(&line, '\0', &line_len, &line_len_max);
                
                // 行をドキュメントとして保存
                if (strlen(line) > 0)
                    insert_document(line);  // 配列に追加
                
                line_len = 0;       // 行の文字数の初期化
                pre_word_id = -1;   // 前回の単語はない
            }
            else
            {
                // 行の場合は空白も入れる
                set_character(&line, c, &line_len, &line_len_max);
            }
            
            if (c == EOF)   // 繰り返しを抜ける
                break;
            
            state = S_SPACE;    // 状態の変更
        }
        // 空白文字でない場合(単語の場合)
        else
        {
            // 文字の保存
            set_character(&word, tolower(c), &word_len, &word_len_max); // 小文字で保存
            set_character(&line, c, &line_len, &line_len_max);
            state = S_WORD; // 状態の変更
        }
    }
    
    // 解放
    fclose(fp);
    free(word);
    free(line);
}
Esempio n. 13
0
void xdsum_add_array( double * s , unsigned n , const double * x )
{
    add_array( s , x , x + n );
}
Esempio n. 14
0
int main() {
    print_array(array, LENGTH);
    add_array(array, LENGTH, 5);
    print_array(array, LENGTH);
    return 0;
}
Esempio n. 15
0
File: mail.c Progetto: wtj/formosa
/*
 * user can modify his list for grouply mail sending
 */
static int
set_group()
{
	char strName[STRLEN];
	int num_send = 0;

	clear();

	prints(_msg_max_group, MAX_MAILGROUPS);

	for (;;)
	{
		/* show the list for grouply mail sending */
		show_array(mgatop);

		getdata(1, 0, _msg_ask_group_add, genbuf, 2, ECHONOSP | LOWCASE, NULL);
		switch (genbuf[0])
		{
		case 'a':
			if (num_send >= MAX_MAILGROUPS)
			{
				prints(_msg_mail_group_max_prompt, MAX_MAILGROUPS);
				getkey();
			}
			else
			{
				if (getdata(2, 0, _msg_receiver, strName, sizeof(strName),
					    ECHONOSP, NULL))
				{
#if EMAIL_LIMIT
					if (curuser.ident != 7 && strchr(strName, '@'))
					{
						prints("\n%s", _msg_sorry_email);
						clrtoeol();
						getkey();
					}
					else
#endif
					if (strchr(strName, '@') || get_passwd(NULL, strName) > 0)
					{
						if (!cmp_array(mgatop, strName, strcmp))
						{
							add_array(mgatop, strName, malloc_str);
							num_send++;
						}
					}
				}
			}
			break;
		case 'f':
			{
				int i;

				load_friend(&friend_cache, curuser.userid);

				for (i = 0; i < friend_cache->number; i++)
				{
					if (!friend_cache->datap[i])
						continue;

					if (num_send >= MAX_MAILGROUPS)
					{
						prints(_msg_mail_group_max_prompt, MAX_MAILGROUPS);
						getkey();
						break;
					}

					if (!cmp_array(mgatop, friend_cache->datap[i], strcmp))
					{
						add_array(mgatop, friend_cache->datap[i], malloc_str);
						num_send++;
					}
				}
			}
			break;
		case 'd':
			if (getdata(2, 0, _msg_delete, genbuf, IDLEN, ECHONOSP, NULL))
			{
				mgatop = cmpd_array(mgatop, genbuf, strcmp);
				num_send--;
			}
			break;
		case 'q':
			return -1;
		case 'e':
		default:
			if (num_send == 0)
				return -1;
			clrtobot();
			return 0;
		}
	}
}
Esempio n. 16
0
AST_Decl *UTL_Scope::call_add()
{
   AST_Decl *result = NULL;
   AST_Decl *decl;

   UTL_ScopeActiveIterator *i;
   UTL_Scope *scope;

   i = new UTL_ScopeActiveIterator(this, UTL_Scope::IK_decls);

   while (!(i->is_done()))
   {
      decl = i->item();
      scope = 0;

      switch (decl->node_type())
      {

      case AST_Decl::NT_argument:
         result = add_argument(AST_Argument::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_array:
         result = add_array(AST_Array::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_attr:
         result = add_attribute(AST_Attribute::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_const:
         result = add_constant(AST_Constant::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_enum:
         scope = AST_Enum::narrow_from_decl(decl);
         result = add_enum(AST_Enum::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_enum_val:
         result = add_enum_val(AST_EnumVal::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_except:
         scope = AST_Exception::narrow_from_decl(decl);
         result = add_exception(AST_Exception::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_field:
         result = add_field(AST_Field::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_interface:
         scope = AST_Interface::narrow_from_decl(decl);
         result = add_interface(AST_Interface::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_interface_fwd:
         result = add_interface_fwd(AST_InterfaceFwd::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_module:
         scope = AST_Module::narrow_from_decl(decl);
         result = add_module(AST_Module::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_op:
         result = add_operation(AST_Operation::narrow_from_decl(decl));
         scope = AST_Operation::narrow_from_decl(decl);
         break;

      case AST_Decl::NT_pre_defined:
         result =
         add_predefined_type(AST_PredefinedType::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_sequence:
         result = add_sequence(AST_Sequence::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_string:
         result = add_string(AST_String::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_struct:
         result = add_structure(AST_Structure::narrow_from_decl(decl));
         scope = AST_Structure::narrow_from_decl(decl);
         break;

      case AST_Decl::NT_typedef:
         result = add_typedef(AST_Typedef::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_union:
         result = add_union(AST_Union::narrow_from_decl(decl));
         scope = AST_Union::narrow_from_decl(decl);
         break;

      case AST_Decl::NT_union_branch:
         result = add_union_branch(AST_UnionBranch::narrow_from_decl(decl));
         break;
         //   case AST_Decl::NT_opaque:
         //  result = add_opaque(AST_Opaque::narrow_from_decl(decl));
         // break;

      case AST_Decl::NT_value:
         result = add_valuetype (AST_Value::narrow_from_decl (decl));
         scope = AST_Value::narrow_from_decl (decl);
         break;

      case AST_Decl::NT_value_fwd:
         result = add_valuetype_fwd(AST_ValueFwd::narrow_from_decl(decl));
         break;

      case AST_Decl::NT_state_member:
         result = add_state_member(AST_StateMember::narrow_from_decl(decl));
         break;

      default:
         return NULL;
      }

      if (scope)
         scope->call_add();

      i->next();
   }

   delete i;
   return result;
}