void init_datatypes() { sem_t *sem_INTEGER; sem_t *sem_REAL; sem_t *sem_BOOLEAN; sem_t *sem_CHAR; //insert the standard types sem_INTEGER = sm_insert("integer",ID_TYPEDEF); sem_INTEGER->comp = (data_t*)calloc(1,sizeof(data_t)); sem_INTEGER->comp->is = TYPE_INT; sem_INTEGER->comp->def_datatype = sem_INTEGER->comp; sem_INTEGER->comp->name = sem_INTEGER->name; sem_INTEGER->comp->memsize = MEM_SIZEOF_INT; SEM_INTEGER = sem_INTEGER->comp; sem_REAL = sm_insert("real",ID_TYPEDEF); sem_REAL->comp = (data_t*)calloc(1,sizeof(data_t)); sem_REAL->comp->is = TYPE_REAL; sem_REAL->comp->def_datatype = sem_REAL->comp; sem_REAL->comp->name = sem_REAL->name; sem_REAL->comp->memsize = MEM_SIZEOF_REAL; SEM_REAL = sem_REAL->comp; sem_BOOLEAN = sm_insert("boolean",ID_TYPEDEF); sem_BOOLEAN->comp = (data_t*)calloc(1,sizeof(data_t)); sem_BOOLEAN->comp->is = TYPE_BOOLEAN; sem_BOOLEAN->comp->def_datatype = sem_BOOLEAN->comp; sem_BOOLEAN->comp->name = sem_BOOLEAN->name; sem_BOOLEAN->comp->memsize = MEM_SIZEOF_BOOLEAN; SEM_BOOLEAN = sem_BOOLEAN->comp; sem_CHAR = sm_insert("char",ID_TYPEDEF); sem_CHAR->comp = (data_t*)calloc(1,sizeof(data_t)); sem_CHAR->comp->is = TYPE_CHAR; sem_CHAR->comp->def_datatype = sem_CHAR->comp; sem_CHAR->comp->name = sem_CHAR->name; sem_CHAR->comp->memsize = MEM_SIZEOF_CHAR; SEM_CHAR = sem_CHAR->comp; usr_datatype = (data_t*)calloc(1,sizeof(data_t)); void_datatype = (data_t*)calloc(1,sizeof(struct data_t)); void_datatype->is = TYPE_VOID; void_datatype->def_datatype = void_datatype; void_datatype->name = "__void_datatype__"; void_datatype->memsize = 0; //(d->is==TYPE_ARRAY && d->field_num==1 && d->def_datatype->is==TYPE_CHAR) VIRTUAL_STRING_DATATYPE = (data_t*)calloc(1,sizeof(data_t)); VIRTUAL_STRING_DATATYPE->is = TYPE_ARRAY; VIRTUAL_STRING_DATATYPE->field_num = 1; VIRTUAL_STRING_DATATYPE->def_datatype = SEM_CHAR; }
pset do_sm_minimum_cover(pset_family A) { sm_matrix *M; sm_row *sparse_cover; sm_element *pe; pset cover; register int i, base, rownum; register unsigned val; register pset last, p; M = sm_alloc(); rownum = 0; for( p=A->data, last= p+A->count*A->wsize; p< last; p+=A->wsize) { for( i = (p[0] & 0x03ff); i > 0; ) for( val = p[ i], base = -- i << 5; val != 0; base++, val >>= 1) if ( val & 1) { (void) sm_insert(M, rownum, base); } rownum++; } sparse_cover = sm_minimum_cover(M, ((int *) 0), 1, 0); sm_free(M); cover = set_clear(((unsigned int *) malloc(sizeof(unsigned int) * ( ((A->sf_size) <= 32 ? 2 : (((((A->sf_size)-1) >> 5) + 1) + 1))))), A->sf_size); for( pe = sparse_cover->first_col; pe != 0; pe = pe->next_col) { (cover[((( pe->col_num) >> 5) + 1)] |= 1 << (( pe->col_num) & (32-1))); } sm_row_free(sparse_cover); return cover; }
static void copy_row(register sm_matrix *A, register sm_row *prow) { register sm_element *p; for(p = prow->first_col; p != 0; p = p->next_col) { (void) sm_insert(A, p->row_num, p->col_num); } }
sm_matrix * sm_dup(sm_matrix *A) { register sm_row *prow; register sm_element *p; register sm_matrix *B; B = sm_alloc(); if (A->last_row != 0) { sm_resize(B, A->last_row->row_num, A->last_col->col_num); for(prow = A->first_row; prow != 0; prow = prow->next_row) { for(p = prow->first_col; p != 0; p = p->next_col) { (void) sm_insert(B, p->row_num, p->col_num); } } } return B; }
void make_type_definition(char *id, data_t *type) { sem_t *sem_1; if (type) { sem_1 = sm_find(id); if (!sem_1) { sem_1 = sm_insert(id,ID_TYPEDEF); //set semantics to symbol sem_1->comp = type; sem_1->comp->name = sem_1->name; } else { free(id); //flex strdup'ed it yyerror("id type declaration already exists"); } } else { free(id); //flex strdup'ed it yyerror("data type NOT defined (debugging info)"); } }