예제 #1
0
void lts_type_serialize(lts_type_t t,stream_t ds){
	DSwriteS(ds,"lts signature 1.1");
	uint32_t N=lts_type_get_state_length(t);
	Warning(debug,"state length is %d",N);
	DSwriteU32(ds,N);
	for(uint32_t i=0;i<N;i++){
		char*x=lts_type_get_state_name(t,i);
		if (x) DSwriteS(ds,x); else DSwriteS(ds,"");
		DSwriteU32(ds,lts_type_get_state_typeno(t,i));
	}
	N=lts_type_get_state_label_count(t);
	Warning(debug,"%d state labels",N);
	DSwriteU32(ds,N);
	for(uint32_t i=0;i<N;i++){
		char*x=lts_type_get_state_label_name(t,i);
		if (x) DSwriteS(ds,x); else DSwriteS(ds,"");
		DSwriteU32(ds,lts_type_get_state_label_typeno(t,i));
	}
	N=lts_type_get_edge_label_count(t);
	Warning(debug,"%d edge labels",N);
	DSwriteU32(ds,N);
	for(uint32_t i=0;i<N;i++){
		char*x=lts_type_get_edge_label_name(t,i);
		if (x) DSwriteS(ds,x); else DSwriteS(ds,"");
		DSwriteU32(ds,lts_type_get_edge_label_typeno(t,i));
		Warning(debug,"edge label %d is %s : %s",i,x,lts_type_get_edge_label_type(t,i));
	}
	N=lts_type_get_type_count(t);
	Warning(debug,"%d types",N);
	DSwriteU32(ds,N);
	for(uint32_t i=0;i<N;i++){
		DSwriteS(ds,lts_type_get_type(t,i));
		DSwriteS(ds,(char*)data_format_string(t,i));
	}
}
예제 #2
0
파일: output.c 프로젝트: alaarman/ltsmin
static void
output_lbls(FILE *tbl_file, vset_t visited)
{
    matrix_t *sl_info = GBgetStateLabelInfo(model);

    nGuards = dm_nrows(sl_info);

    if (dm_nrows(sl_info) != lts_type_get_state_label_count(ltstype))
        Warning(error, "State label count mismatch!");

    for (int i = 0; i < nGuards; i++){
        int len = dm_ones_in_row(sl_info, i);
        int used[len];

        // get projection
        for (int pi = 0, pk = 0; pi < dm_ncols (sl_info); pi++) {
            if (dm_is_set (sl_info, i, pi))
                used[pk++] = pi;
        }

        vset_t patterns = vset_create(domain, len, used);
        map_context ctx;

        vset_project(patterns, visited);
        ctx.tbl_file = tbl_file;
        ctx.mapno = i;
        ctx.len = len;
        ctx.used = used;
        fprintf(tbl_file, "begin map ");
        fprint_ltsmin_ident(tbl_file, lts_type_get_state_label_name(ltstype,i));
        fprintf(tbl_file, ":");
        fprint_ltsmin_ident(tbl_file, lts_type_get_state_label_type(ltstype,i));
        fprintf(tbl_file,"\n");
        vset_enum(patterns, enum_map, &ctx);
        fprintf(tbl_file, "end map\n");
        vset_destroy(patterns);
    }
}
예제 #3
0
파일: pins-open.c 프로젝트: graydon/ltsmin
CAESAR_TYPE_STRING CAESAR_STRING_LABEL(CAESAR_TYPE_LABEL l) {
	static char *s = NULL;  /* start of string */
	static char *b = NULL; /*beyond*/
	static char *tau = "i";
	char *p = NULL;  /* current insertion point */
	int u, n; /* used, needed */
	int i;
	chunk c;
	size_t clen;
	
	p = s;
	n = 5;
	if (b-p < n) { 
		u = p-s;
		s = RTrealloc(s, u+n);/* TODO: check s!=0 */
		p = s+u;
		b = s + u+n;
	}
    if (edge_labels > 0 && l->label[0]<0){
        n = 6;
        if (b-p < n) { 
            u = p-s;
            s = RTrealloc(s, u+n); /* TODO: check s!=0 */
            p = s+u;
            b = s + u+n;
        }
        sprintf(p, "delta");
        p+=strlen(p);
    } else {
        if (edge_labels > 1 || edge_encode) {
                sprintf(p, "|");
                p += strlen(p);
        }
        for(i=0; i < edge_labels; i++) {
            char *name=lts_type_get_edge_label_name(ltstype,i);
            c=GBchunkGet(model,lts_type_get_edge_label_typeno(ltstype,i),l->label[i]);
            if (c.len==3 && strncmp(c.data, LTSMIN_EDGE_VALUE_TAU, c.len)==0)
                clen=strlen(tau);
            else
                clen=c.len*2+6;
            n = strlen(name)+ 1 + clen+1+1+1; /* for name , '=' , c, ';',  '>', '\0' */
            if (b-p < n) { 
                u = p-s;
                s = RTrealloc(s, u+n); /* TODO: check s!=0 */
                p = s+u;
                b = s + u+n;
            }
            if (i>0) {
                sprintf(p, "|");
                p += strlen(p);
            }
            if (edge_labels > 1 || edge_encode ) {
                sprintf(p, "%s=",name);
                p += strlen(p);
            }
            if (c.len==3 && strncmp(c.data, LTSMIN_EDGE_VALUE_TAU, c.len)==0)
                sprintf(p, "%s", tau);
            else
                chunk2string(c,b-p,p);
            p += strlen(p);
        }
    }
    if (edge_labels > 1 || edge_encode ) {
        sprintf(p, "|");
        p += strlen(p);
    }
    if (edge_encode){
        int ofs=edge_labels;
        /*
        for(i=0;i<N;i++){
            char*name=lts_type_get_state_name(ltstype,i);
            c=GBchunkGet(model,lts_type_get_state_typeno(ltstype,i),l->label[ofs+i]);
            n=strlen(name)+c.len*2+7;
            if (b-p < n) { 
                u = p-s;
                s = realloc(s, u+n); // TODO: check s!=0
                p = s+u;
                b = s + u+n;
            }
            sprintf(p, "%s=",name);
            p+=strlen(p);
            chunk2string(c,b-p,p);
            p+=strlen(p);
            sprintf(p, "|");
            p +=strlen(p);
        }
        */
        ofs+=N;
        for(i=0;i<state_labels;i++){
            char*name=lts_type_get_state_label_name(ltstype,i);
            c=GBchunkGet(model,lts_type_get_state_label_typeno(ltstype,i),l->label[ofs+i]);
            n=strlen(name)+c.len*2+7;
            if (b-p < n) { 
                u = p-s;
                s = RTrealloc(s, u+n); /* TODO: check s!=0 */
                p = s+u;
                b = s + u+n;
            }
            sprintf(p, "%s=",name);
            p+=strlen(p);
            chunk2string(c,b-p,p);
            p+=strlen(p);
            sprintf(p, "|");
            p +=strlen(p);
       }
    }
    return s;
}