示例#1
0
文件: string.c 项目: headius/jato
static unsigned long string_obj_hash(const void *key)
{
	struct vm_object *array;
	unsigned long hash;
	jint offset;
	jint count;

	offset = field_get_int(key, vm_java_lang_String_offset);
	count = field_get_int(key, vm_java_lang_String_count);
	array = field_get_object(key, vm_java_lang_String_value);

	hash = 0;

	for (jint i = 0; i < count; i++)
		hash += 31 * hash + array_get_field_char(array, i + offset);

	return hash;
}
示例#2
0
文件: string.c 项目: headius/jato
/*
 * Compare key1 string and key2 weak reference to string.
 */
static bool string_obj_equals(const void *key1, const void *key2)
{
	struct vm_object *array1, *array2;
	jint offset1, offset2;
	jint count1, count2;

	count1 = field_get_int(key1, vm_java_lang_String_count);
	count2 = field_get_int(key2, vm_java_lang_String_count);

	if (count1 != count2)
		return false;

	offset1 = field_get_int(key1, vm_java_lang_String_offset);
	offset2 = field_get_int(key2, vm_java_lang_String_offset);

	array1 = field_get_object(key1, vm_java_lang_String_value);
	array2 = field_get_object(key2, vm_java_lang_String_value);

	int fsize = vmtype_get_size(J_CHAR);

	return memcmp(vm_array_elems(array1) + offset1 * fsize,
		      vm_array_elems(array2) + offset2 * fsize,
		      count1 * fsize) == 0;
}
示例#3
0
文件: string.c 项目: siam/jato
static int string_obj_comparator(const void *key1, const void *key2)
{
	struct vm_object *array1, *array2;
	jint offset1, offset2;
	jint count1, count2;

	count1 = field_get_int(key1, vm_java_lang_String_count);
	count2 = field_get_int(key2, vm_java_lang_String_count);

	if (count1 != count2)
		return -1;

	offset1 = field_get_int(key1, vm_java_lang_String_offset);
	offset2 = field_get_int(key2, vm_java_lang_String_offset);

	array1 = field_get_object(key1, vm_java_lang_String_value);
	array2 = field_get_object(key2, vm_java_lang_String_value);

	int fsize = get_vmtype_size(J_CHAR);

	return memcmp(array1->fields + offset1 * fsize,
		      array2->fields + offset2 * fsize,
		      count1 * fsize);
}
示例#4
0
文件: reflection.c 项目: abak/jato
struct vm_field *vm_object_to_vm_field(struct vm_object *field)
{
	struct vm_object *class;
	struct vm_class *vmc;
	int slot;

	if (!field)
		return throw_npe();

	if (vm_java_lang_reflect_VMField != NULL) {	/* Classpath 0.98 */
		if (vm_object_is_instance_of(field, vm_java_lang_reflect_Field))
			field	= field_get_object(field, vm_java_lang_reflect_Field_f);

		class	= field_get_object(field, vm_java_lang_reflect_VMField_clazz);
		slot	= field_get_int(field, vm_java_lang_reflect_VMField_slot);
	} else {
示例#5
0
文件: reflection.c 项目: abak/jato
	struct vm_object *class;
	struct vm_class *vmc;
	int slot;

	if (!field)
		return throw_npe();

	if (vm_java_lang_reflect_VMField != NULL) {	/* Classpath 0.98 */
		if (vm_object_is_instance_of(field, vm_java_lang_reflect_Field))
			field	= field_get_object(field, vm_java_lang_reflect_Field_f);

		class	= field_get_object(field, vm_java_lang_reflect_VMField_clazz);
		slot	= field_get_int(field, vm_java_lang_reflect_VMField_slot);
	} else {
		class	= field_get_object(field, vm_java_lang_reflect_Field_declaringClass);
		slot	= field_get_int(field, vm_java_lang_reflect_Field_slot);
	}

	vmc = vm_class_get_class_from_class_object(class);
	if (!vmc)
		return throw_npe();

	vm_class_ensure_init(vmc);
	if (exception_occurred())
		return NULL;

	return &vmc->fields[slot];
}

struct vm_object *vm_method_to_java_lang_reflect_method(struct vm_method *vmm, jobject clazz, int method_index)
{