Ejemplo n.º 1
0
const fieldInClass* getFieldInClassbyLinkId(u2 classId, u2 linkId) {
	u2 referencedClassId = classId;
	int i;
	const fieldInClass* fic = NULL;
	while (fic == NULL) {
		const constantPool* cpool = &allConstantPools[referencedClassId];
		const fieldInClass* allFields = cpool->fields;
		size_t numberOfAllFields = cpool->numberOfFields;
		for (i = 0; i < numberOfAllFields && fic == NULL; i++) {
			if (allFields[i].linkId == linkId) {
				fic = &allFields[i];
			}
		}
		if (fic == NULL) {
			if (referencedClassId != JAVA_LANG_OBJECT_CLASS_ID) {
				// Look in super class:
				referencedClassId = getSuperClass(referencedClassId);
			} else {
				// Already in java.lang.Object; symbol not found.
				break;
			}
		}
	}

	if (fic == NULL) {
		consout("Failed to look up field entry: classId = %d, linkId=%d\n", classId, linkId);
		jvmexit(1);
	}

	return fic;
}
Ejemplo n.º 2
0
bool isObjCInterfaceClassOrSubclass(
    const clang::ObjCInterfaceDecl* decl, const std::string& className) {
    for(auto current = decl; current != nullptr; current = current->getSuperClass()) {
        if(current->getNameAsString() == className) {
            return true;
        }
    }
    return false;
}
Ejemplo n.º 3
0
const methodInClass* getVirtualMethodEntryByLinkId(jobject jref, u2 linkId) {
	BEGIN;

	int referencedClassId = oaGetClassIdFromObject(jref);
	//printf("classId = %d, obj= %p\n", (int) referencedClassId, jref);
	//jvmexit(1);
	// Lookup method in referenced class or in it's super-classes:
	const methodInClass* mic = NULL;
	while (mic == NULL) {
		//		for (i = 0; i < numberOfAllMethodsInAllClasses && !found; i++) {
		//			if (allMethodsInAllClasses[i].classId == referencedClassId
		//					&& allMethodsInAllClasses[i].linkId == linkId) {
		//				found = TRUE;
		//				methodId = i;
		//			}
		//		}
		mic = getMethodInClass(referencedClassId, linkId);
		if (mic == NULL) {
			// Not found:
			if (referencedClassId != JAVA_LANG_OBJECT_CLASS_ID) {
				// Look in super class:
				CALL(referencedClassId = getSuperClass(referencedClassId))
				;
			} else {
				// Already in java.lang.Object; symbol not found.
				break;
			}
		}
	}

	//printf("mic found: %d, refclassid = %d\n", found, referencedClassId);
	if (mic == NULL) {
		consout("Failed to look up virtual method entry: referencedClass = %d, linkId=%d\n",
				oaGetClassIdFromObject(jref), linkId);
		jvmexit(1);
	}
	END;

	return mic;
}