inventory &inventory::operator+= (const inventory &rhs)
{
    for (size_t i = 0; i < rhs.size(); i++) {
        add_stack(rhs.const_stack(i));
    }
    return *this;
}
Beispiel #2
0
int main() {
  assertTrueWMsg(phyPages() <= 16, "too many pages to run this test.");
  if(phyPages() > 64)
	  fail();
  swapSize = getSwapSize();
  assertTrue(swapSize > 0);
  if(add_stack(2) == -1)
	  fail();
  done();
  return 0;
}
void		prioprs(t_token **stack, t_token *token, t_list *st_list)
{
  t_token	*tmp2;

  if ((*stack) == NULL)
    {
      add_stack(stack, token);
    }
  else if (token->priority > (*stack)->priority)
    {
      add_stack(stack, token);
    }
  else
    {
      while (*stack != NULL && token->priority <= (*stack)->priority)
	{
	  tmp2 = (*stack)->next;
	  add_to_list(st_list, *stack);
	  *stack = tmp2;
	}
      add_stack(stack, token);
    }
}
Beispiel #4
0
int add_stack(int depth) {
  int i, j;
  int old = swapSize;
  for(j = 0;j < MATRIX_SIZE;++j)
	  for(i = 0;i < MATRIX_SIZE;++i)
		  arr[i][j] = valueAt(i, j);
  swapSize = getSwapSize();
  assertTrue(swapSize >= old);
  if (depth > 1)
    if(add_stack(depth - 1) == -1)
		fail();
  for(j = 0;j < MATRIX_SIZE;++j)
	  for(i = 0;i < MATRIX_SIZE;++i)
		  if(!arr[i][j] == valueAt(i, j)) {
			  printf("incorrect value!\n");
			  fail();
		  }
}
Beispiel #5
0
int collect_dlr(void) {

  struct reference *r;
  struct stack *s;
  struct label *l;
  int section, x, i, n, q;
  unsigned char *t, *dtmp;
  double dou;

  
  section = 0;
  obj_tmp = obj_first;
  while (obj_tmp != NULL) {
    /* OBJECT FILE */
    if (obj_tmp->format == WLA_VERSION_OBJ) {
      t = obj_tmp->exported_defines;
      i = READ_T;

      /* load defines */
      for (; i > 0; i--) {
	l = calloc(1, sizeof(struct label));
	if (l == NULL) {
	  fprintf(stderr, "COLLECT_DLR: Out of memory.\n");
	  return FAILED;
	}

	/* copy the name */
	for (x = 0; !(*t == 0 || *t == 1); t++, x++)
	  l->name[x] = *t;
	l->name[x] = 0;
	if (*t == 0)
	  l->status = LABEL_STATUS_DEFINE;
        else if (*t == 1)
	  l->status = LABEL_STATUS_STACK;
	else {
	  fprintf(stderr, "COLLECT_DLR: Unknown definition type \"%d\".\n", *t);
	  return FAILED;
	}
	t++;

	READ_DOU;
	l->address = dou;
	l->base = 0;
	l->file_id = obj_tmp->id;
	l->section_status = OFF;
        l->section_struct = NULL;

	add_label(l);
      }

      /* load labels */
      i = READ_T;

      for (; i > 0; i--) {
	l = calloc(1, sizeof(struct label));
	if (l == NULL) {
	  fprintf(stderr, "COLLECT_DLR: Out of memory.\n");
	  return FAILED;
	}
	for (x = 0; !(*t == 0 || *t == 1 || *t == 2); t++, x++)
	  l->name[x] = *t;
	l->name[x] = 0;
	
	if (*t == 0)
	  l->status = LABEL_STATUS_LABEL;
        else if (*t == 1)
	  l->status = LABEL_STATUS_SYMBOL;
        else if (*t == 2)
	  l->status = LABEL_STATUS_BREAKPOINT;
	else {
	  fprintf(stderr, "COLLECT_DLR: Unknown label type \"%d\".\n", *t);
	  return FAILED;
	}

	t++;
	l->slot = *(t++);
	l->file_id_source = *(t++);

	l->section = READ_T;
	if (l->section == 0)
	  l->section_status = OFF;
	else {
	  l->section_status = ON;
	  l->section += section;
	}
	l->address = READ_T;
	l->linenumber = READ_T;
	l->base = (((int)l->address) >> 16) & 0xFF;
	l->address = ((int)l->address) & 0xFFFF;
	l->bank = READ_T;
	l->file_id = obj_tmp->id;
        l->section_struct = NULL;

	add_label(l);
      }

      i = READ_T;

      /* load references */
      for (; i > 0; i--) {
	r = malloc(sizeof(struct reference));
	if (r == NULL) {
	  fprintf(stderr, "COLLECT_DLR: Out of memory.\n");
	  return FAILED;
	}
	for (x = 0; *t != 0; t++, x++)
	  r->name[x] = *t;
	r->name[x] = 0;
	t++;
	r->type = *(t++);
	r->file_id_source = *(t++);
	r->slot = *(t++);
	r->section = READ_T;
	if (r->section == 0)
	  r->section_status = OFF;
	else {
	  r->section_status = ON;
	  r->section += section;
	}
	r->linenumber = READ_T;
	r->address = READ_T;
	r->bank = READ_T;

	add_reference(r);
      }

      i = READ_T;

      /* load pending calculations */
      for (; i > 0; i--) {
	s = malloc(sizeof(struct stack));
	if (s == NULL) {
	  fprintf(stderr, "COLLECT_DLR: Out of memory.\n");
	  return FAILED;
	}

	s->id = READ_T;
	s->type = *(t++);
	s->section = READ_T;
	if (s->section == 0)
	  s->section_status = OFF;
	else {
	  s->section_status = ON;
	  s->section += section;
	}
	s->file_id_source = *(t++);
	x = *(t++);
	s->position = *(t++);
	s->slot = *(t++);
	s->address = READ_T;
	s->linenumber = READ_T;
	s->bank = READ_T;
	s->stacksize = x;
	
	s->stack = malloc(sizeof(struct stackitem) * x);
	if (s->stack == NULL) {
	  fprintf(stderr, "COLLECT_DLR: Out of memory.\n");
	  free(s);
	  return FAILED;
	}
	
	add_stack(s);

	for (n = 0; n != x; n++) {
	  s->stack[n].type = *(t++);
	  s->stack[n].sign = *(t++);
	  if (s->stack[n].type == STACK_ITEM_TYPE_STRING) {
	    for (q = 0; *t != 0; t++, q++)
	      s->stack[n].string[q] = *t;
	    s->stack[n].string[q] = 0;
	    t++;
	  }
	  else {
	    READ_DOU;
	    s->stack[n].value = dou;
	  }
	}
      }

      /* save pointer to data block area */
      obj_tmp->data_blocks = t;
    }
    /* LIBRARY FILE */
    else if (obj_tmp->format == WLA_VERSION_LIB) {
Beispiel #6
0
void inventory::push_back(std::vector<item> newits)
{
 add_stack(newits);
}
Beispiel #7
0
inventory& inventory::operator+= (inventory &rhs)
{
 for (int i = 0; i < rhs.size(); i++)
  add_stack(rhs.stack_at(i));
 return *this;
}
Beispiel #8
0
void *op_brick_add(t_brick *brick)
{
	t_context *C = ctx_get();
	t_node *node = NULL;
	t_block *block;
	t_set *set;

	// store
	scene_store(C->scene,1);

	char *name=brick->id.name;

	     if(is(name,"frame")) 		node = add_slider_int(C,"frame",&C->app->frame); 
	else if(is(name,"timer"))  		node = add_slider_float(C,"timer",&C->app->timer); 
	else if(is(name,"timer low"))  		node = add_slider_float(C,"timer low",&C->app->timer_add_low); 
	else if(is(name,"=")) 			node = add_operator_double(C,"=");
	else if(is(name,">"))  			node = add_operator_double(C,">"); 
	else if(is(name,"<"))  			node = add_operator_double(C,"<"); 
	else if(is(name,"if")) 			node = add_if(C); 
	else if(is(name,"mod"))  		node = add_operator_double(C,"mod"); 
	else if(is(name,"x")) 			node = add_maths(C,"x");
	else if(is(name,"+"))  			node = add_maths(C,"+"); 
	else if(is(name,"++")) 			node = add_plusplus(C);
	else if(is(name,"switch"))  		node = add_switch(C,"switch",NULL,NULL); 
	else if(is(name,"clone"))  		node = add_clone(C); 
	else if(is(name,"pipe")) 		node = add_pipe(C); 
	else if(is(name,"sec")) 		node = add_slider_int(C,"sec",&C->app->clock->sec);
	else if(is(name,"min")) 		node = add_slider_int(C,"min",&C->app->clock->min);
	else if(is(name,"int")) 		node = add_slider_int(C,"int",NULL);
	else if(is(name,"float")) 		node = add_slider_float(C,"float",NULL);
	else if(is(name,"10")) 			node = add_multiplier(C,"10");
	else if(is(name,"100")) 		node = add_multiplier(C,"100");
	else if(is(name,".1")) 			node = add_multiplier(C,".1");
	else if(is(name,".01")) 		node = add_multiplier(C,".01");
	else if(is(name,".001")) 		node = add_multiplier(C,".001");
	else if(is(name,"msec")) 		node = add_slider_int(C,"msec",&C->app->clock->msec);
	else if(is(name,"cos")) 		node = add_operator_single(C,"cos",op_cos);
	else if(is(name,"sin")) 		node = add_operator_single(C,"sin",op_sin);
	else if(is(name,"cam_eye_x")) 		node = add_slider_camera(C,"eye x");
	else if(is(name,"cam_eye_y")) 		node = add_slider_camera(C,"eye y");
	else if(is(name,"cam_eye_z")) 		node = add_slider_camera(C,"eye z");
	else if(is(name,"cam_pos_x")) 		node = add_slider_camera(C,"pos x");
	else if(is(name,"cam_pos_y")) 		node = add_slider_camera(C,"pos y");
	else if(is(name,"cam_pos_z")) 		node = add_slider_camera(C,"pos z");
	else if(is(name,"cam_rot_xy")) 		node = add_slider_float_custom(C,"cam rot xy",op_camera_rotate_xy); 
	else if(is(name,"cam_rot_z")) 		node = add_slider_float_custom(C,"cam rot z",op_camera_rotate_z); 
	else if(is(name,"pos x")) 		node = add_slider_object(C,"pos x");
	else if(is(name,"pos y")) 		node = add_slider_object(C,"pos y");
	else if(is(name,"pos z")) 		node = add_slider_object(C,"pos z");
	else if(is(name,"rot x")) 		node = add_slider_object(C,"rot x");
	else if(is(name,"rot y")) 		node = add_slider_object(C,"rot y");
	else if(is(name,"rot z")) 		node = add_slider_object(C,"rot z");
	else if(is(name,"scl x")) 		node = add_slider_object(C,"scl x");
	else if(is(name,"scl y")) 		node = add_slider_object(C,"scl y");
	else if(is(name,"scl z")) 		node = add_slider_object(C,"scl z");
	else if(is(name,"red")) 		node = add_slider_object(C,"red");
	else if(is(name,"green")) 		node = add_slider_object(C,"green");
	else if(is(name,"blue")) 		node = add_slider_object(C,"blue");
	else if(is(name,"color")) 		node = add_slider_object(C,"color");
	else if(is(name,"faces")) 		node = add_slider_object(C,"faces");
	else if(is(name,"alpha")) 		node = add_slider_object(C,"alpha");
	else if(is(name,"label")) 		node = add_label(C,"label");
	else if(is(name,"get")) 		node = add_get(C);
	else if(is(name,"rewind")) 		node = add_trigger_always(C,"rewind",op_rewind); 
	else if(is(name,"not")) 		node = add_slider_int_custom(C,"not",NULL,op_not); 
	else if(is(name,"mouse_x")) 		node = add_slider_int(C,"mouse x",&C->app->mouse->x); 
	else if(is(name,"mouse_y")) 		node = add_slider_int(C,"mouse y",&C->app->mouse->y); 
	else if(is(name,"keyboard")) 		node = add_slider_char(C,"keyboard",&C->app->keyboard->key_pressed); 
	else if(is(name,"rnd")) 		node = add_slider_int_custom(C,"rnd",NULL,op_rnd);
	else if(is(name,"neg")) 		node = add_slider_int_custom(C,"neg",NULL,op_neg);
	else if(is(name,"abs")) 		node = add_slider_int_custom( C, "abs", NULL, op_abs); 
	else if(is(name,"last?")) 		node = add_switch(C,"last?",NULL,op_is_last);
	else if(is(name,"for")) 		node = add_for(C);
	else if(is(name,"vector 3d")) 		node = add_vector_3d(C);
	else if(is(name,"vector 2d")) 		node = add_vector_2d(C);
	else if(is(name,"bang")) 		node = add_slider_int_custom(C,"bang",NULL,op_bang); 
	else if(is(name,"quit")) 		node = add_trigger_always(C,"quit",op_do_quit); 
	else if(is(name,"const")) 		node = add_const(C); 
	else if(is(name,"and")) 		node = add_maths(C,"and"); 
	else if(is(name,"stack")) 		node = add_stack(C); 
	else if(is(name,"mesh")) 		node = add_slider_object(C,"mesh"); 
	else if(is(name,"vertex")) 		node = add_brick_mesh(C,"vertex"); 
	else if(is(name,"edges")) 		node = add_brick_mesh(C,"edges"); 
	else if(is(name,"case")) 		node = add_case(C,"switch"); 

	// Store
	scene_store(C->scene,0);

	term_log("+ brick");

	// Switch Desk
	if(!C->ui->show_sets) show_sets(C);

	if( node)
	{
		block = node->data;
		set = block->set;
		set_setup( set);
	}
		
	return NULL;
}
 void push(T val) {
   if (stacks.front().size() == limit) {
     add_stack();
   }
   stacks.front().push(val);
 }
 SetOfStacks(int _limit) : limit(_limit) {
   add_stack();
 }