示例#1
0
void opcode_dict_serialize(opcode_dict_t od, writer_t w) {
	long i,j,tot;
	const char* name;
	/* write header */
	write_string(w,"DIC");
	/* write number of opcode arrays */
	write_word(w,OpcodeTypeMax);

	/* now for each array */
	for(i=0;i<OpcodeTypeMax;i+=1) {
		tot = dynarray_size(&od->stub_by_index[i]);
		/* write number of records in array */
		write_word(w,tot);
		/* now for each record */
		for(j=0;j<tot;j+=1) {
			/* retrieve name */
			name = opcode_name_by_stub( od, (opcode_stub_t) dynarray_get( &od->stub_by_index[i], j));
			/* write string length */
			write_word(w,1+strlen(name));
			/* write string */
			write_string(w,name);
		}
		/* write 0xFFFFFF to end the record */
			write_word(w,0xFFFFFFFF);
	}
}
示例#2
0
da_numeric_t dynarray_get(dynarray_t *da, int i)
{
    assert(i >= 0);

    if (!da) {
        da_numeric_t v;
        return v;
    }

    if (i >= DYNARRAY_ALEN)
        return dynarray_get(da->next, i-DYNARRAY_ALEN);
    else
        return da->a[i];
}
示例#3
0
文件: dynarray.c 项目: cslab-ntua/csx
void *dynarray_alloc_nr(struct dynarray *da, unsigned long nr)
{
	void *ret;
	while (da->next_idx + nr > da->elems_nr) {
	    printf("%lu vs %lu\n", da->next_idx, da->elems_nr);
		dynarray_expand(da);
	}

	unsigned long idx = da->next_idx;
	da->next_idx += nr;
	ret = dynarray_get(da, idx);

	return ret;
}
示例#4
0
文件: dynarray.c 项目: cslab-ntua/csx
void *dynarray_get_last(struct dynarray *da)
{
	return dynarray_get(da, da->next_idx-1);
}
示例#5
0
opcode_stub_t opcode_stub_by_code(opcode_dict_t od, word_t wordcode) {
	return (opcode_stub_t) dynarray_get(&od->stub_by_index[WC_GET_ARGTYPE(wordcode)], WC_GET_OP(wordcode));
}