Ejemplo n.º 1
0
void evidence_cl_print()
{
    colorlist *test_cl = (colorlist*)malloc(sizeof(colorlist));
    color *c1 = (color*)malloc(sizeof(color));
    c1->r = 1;
    c1->g = 1;
    c1->b = 1;
    color *c2 = (color*)malloc(sizeof(color));
    c2->r = 0;
    c2->g = 0.5;
    c2->b = 0.7;
    test_cl->c = *c1;
    colorlist *root = (colorlist*)malloc(sizeof(colorlist));
    root->next = 0;
    root->c = *c2;
    test_cl->next = root;
    colorlist *my_cl = cl_cons(c1, test_cl);
    
    printf("*** testing cl_print\n");
    cl_print(test_cl);
    printf("\n");
    cl_print(my_cl);
    
    free(c1);
    free(c2);
    free(root);
    free(test_cl);
}
Ejemplo n.º 2
0
/* test the colorlist structs and its functions */ 
void evidence_colorlist() { 

    printf("TESTING COLORLIST\n\n"); 

    int size = 6; 
    color* colors [6]; 
    double param = 0.2; 
    for(int i = 0; i < size; ++i) { 
	colors[i] = color_new(i * param, i * param, i * param); 
    } 

    colorlist* cl = cl_cons( colors[0], NULL);
    colorlist* tmp = cl; 	
    for(int i = 1; i < 6; ++i) { 
	tmp -> next = cl_cons( colors[i], NULL); 
	tmp = tmp -> next; 
    }

    cl_print(cl); 

    printf("expected length: 6\t|actual: %d\n", cl_length(cl) );  
    printf("expected max red: 1.000\t|actual: %.3f\n", cl_max_red(cl) ); 
    
    //test null cl
    colorlist* nada = NULL; 
    printf("expected length: 0\t|actual: %d\n", cl_length(nada) ); 

    cl_max_red(nada);  

} 
Ejemplo n.º 3
0
void show_cl_type(sCLType* self, sCLClass* klass, sVMInfo* info)
{
    int i;

    if(self == NULL) {
        cl_print(info, "NULL");
    }
    else if(self->mGenericsTypesNum == 0) {
        cl_print(info, "%s", CONS_str(&klass->mConstPool, self->mClassNameOffset));
    }
    else {
        cl_print(info, "%s<", CONS_str(&klass->mConstPool, self->mClassNameOffset));
        for(i=0; i<self->mGenericsTypesNum; i++) {
            show_cl_type(self->mGenericsTypes[i], klass, info);
            if(i != self->mGenericsTypesNum-1) { cl_print(info, ","); }
        }
        cl_print(info, ">");
    }
}
Ejemplo n.º 4
0
int rules_to_c_code()
  {
   char *file_name;
   VALUE arg_ptr;
   int arg_count, i;
   int other_args[5];

   /*===========================================*/
   /* Initialize parameters for handling array  */
   /* syntax for empty arrays.                  */ 
   /*===========================================*/

   first_pn = first_join = first_list = TRUE;
   first_ptest = first_itest = first_ftest = TRUE;
   first_dfact = first_fact = first_elem = TRUE;
   
   /*===========================================*/
   /* Initialize counters to determine indices  */
   /* for setting pointers within arrays.       */
   /*===========================================*/

   mark_pat_count = 0;
   list_count = 0;
   pnode_count = 0;
   icount = fcount = pcount = 0;
   join_count = 0;
   fact_ct = fact_pct = dfact_ct = 0;
   elm_ct = 0;

   /*============================================*/
   /* Check for appropriate number of arguments. */
   /*============================================*/
   
   arg_count = num_args();
   
   if (arg_count < 2)
     { 
      exp_num_error("rules-to-c",AT_LEAST,2);
      return (0);
     }
   else if (arg_count > 6)
     {
      exp_num_error("rules-to-c",NO_MORE_THAN,6);
      return (0);
     }

   /*====================================*/
   /* Get the file name to place C code. */
   /*====================================*/
  
   runknown(1,&arg_ptr);
   if ((arg_ptr.type) != STRING && (arg_ptr.type) != WORD)
     {
      exp_type_error("rules-to-c",1,"WORD or STRING");
      return (0);
     }
   file_name = rvalstring(arg_ptr);

#if VMS || IBM_MSC || IBM_LATTICE || IBM_TBC || IBM_ZTC
   /*Check for '.' VAX or IBM PC file_name */
   for(i=0;*(file_name+i);i++)
     {
      if(*(file_name+i) == '.')
        {
         cl_print("werror","Invalid file name ");
         cl_print("werror",file_name);
         cl_print("werror"," contains \'.\'\n");
         return(1);
        }
      }
#endif
   
   /*==============================*/
   /* Get the remaining arguments. */
   /*==============================*/
   
   other_args[1] = sizeof(char);
   other_args[2] = sizeof(int);
   other_args[3] = sizeof(float);
   other_args[4] = sizeof(char *);
   
   for (i = 2 ; i <= arg_count ; i++)
     {
      runknown(i,&arg_ptr);
      if ((arg_ptr.type) != NUMBER)
        {
         cl_print("werror","Function rules-to-c expected a number as argument #");
         print_num("werror",(float) i);
         cl_print("werror","\n");
         return (0);
        }
      other_args[i-2] = (int) rvalfloat(arg_ptr);
     }
   
   return(generate_code(file_name,other_args[0],other_args[1],
                 other_args[2],other_args[3],other_args[4]));
  }