use of com.jopdesign.common.FieldInfo in project jop by jop-devel.
the class AllocationWcetModel method getObjectFields.
public List<Type> getObjectFields(String className) {
List<Type> l = new LinkedList<Type>();
ClassInfo cli = project.getAppInfo().getClassInfo(className);
if (cli.getSuperClassName() != null) {
l.addAll(getObjectFields(cli.getSuperClassName()));
}
for (FieldInfo f : cli.getFields()) {
if (!f.isStatic()) {
l.add(f.getType());
}
}
return l;
}
use of com.jopdesign.common.FieldInfo in project jop by jop-devel.
the class DescendingClassTraverser method visitClass.
public boolean visitClass(ClassInfo classInfo) {
if (!visitor.visitClass(classInfo)) {
return returnOnSkipClass;
}
visitConstantPool(classInfo);
// methods and fields are final, no need to call accept()
for (FieldInfo f : classInfo.getFields()) {
if (!visitor.visitField(f)) {
continue;
}
bcelVisitor.setFieldInfo(f);
visitAttributes(f.getAttributes());
visitor.finishField(f);
}
for (MethodInfo m : classInfo.getMethods()) {
if (!visitor.visitMethod(m)) {
continue;
}
bcelVisitor.setMethodInfo(m);
visitMethodCode(m);
visitAttributes(m.getAttributes());
visitor.finishMethod(m);
}
bcelVisitor.setClassInfo(classInfo);
visitAttributes(classInfo.getAttributes());
visitor.finishClass(classInfo);
return true;
}
use of com.jopdesign.common.FieldInfo in project jop by jop-devel.
the class ConstantPoolReferenceFinder method findPoolReferences.
////////////////////////////////////////////////////////////////
// Find/replace references, member names, Pool entries
////////////////////////////////////////////////////////////////
public static Set<Integer> findPoolReferences(ClassInfo classInfo, boolean checkMembers) {
JavaClass javaClass = classInfo.compile();
Set<Integer> ids = findPoolReferences(classInfo, javaClass);
if (checkMembers) {
for (Field field : javaClass.getFields()) {
FieldInfo fieldInfo = classInfo.getFieldInfo(field.getName());
ids.addAll(findPoolReferences(fieldInfo, field));
}
for (Method method : javaClass.getMethods()) {
MethodInfo methodInfo = classInfo.getMethodInfo(method.getName() + method.getSignature());
ids.addAll(findPoolReferences(methodInfo, method));
}
}
return ids;
}
use of com.jopdesign.common.FieldInfo in project jop by jop-devel.
the class UsedCodeFinder method markUsedMembers.
public void markUsedMembers(ClassInfo rootClass, boolean visitMembers) {
// has already been visited before, do not recurse down again.
if (!visitMembers && setMark(rootClass, true) == Mark.USED)
return;
// visit superclass and interfaces, attributes, but not methods or fields
if (logger.isTraceEnabled()) {
logger.trace("Visiting references of " + rootClass);
}
Set<String> found = ConstantPoolReferenceFinder.findReferencedMembers(rootClass, false);
visitReferences(found);
if (visitMembers) {
for (FieldInfo field : rootClass.getFields()) {
markUsedMembers(field);
}
for (MethodInfo method : rootClass.getMethods()) {
markUsedMembers(method);
}
} else {
// at least we need to visit the static initializer
MethodInfo clinit = rootClass.getMethodInfo(ClinitOrder.clinitSig);
if (clinit != null) {
markUsedMembers(clinit);
}
// TODO if this implements Runnable, we could also mark the run() method, but using the callgraph
// to find used threads is a bit more flexible
}
}
use of com.jopdesign.common.FieldInfo in project jop by jop-devel.
the class UsedCodeFinder method visitReferences.
private void visitReferences(Set<String> refs) {
for (String id : refs) {
// The member IDs returned by the reference finder use a syntax which is
// always unique, so if in doubt, we need to interpret it as a classname, not a fieldname
MemberID sig = MemberID.parse(id, false);
// find/load the corresponding classInfo
ClassInfo cls = getClassInfo(sig);
// class has been excluded from loading, skip this class
if (cls == null) {
continue;
}
// referenced class is used, visit it if it has not yet been visited, but skip its class members
// Note that this class might be different than the class containing the class member
markUsedMembers(cls, false);
// check if this id specifies a class member (or just a class, in this case we are done)
if (sig.hasMethodSignature()) {
// It's a method! mark the method as used (implementations are marked later)
MethodRef ref = appInfo.getMethodRef(sig);
MethodInfo method = ref.getMethodInfo();
// we keep the declarations. We mark it without following it and make it abstract later.
if (method != null) {
setMark(method, false);
}
} else if (sig.hasMemberName()) {
// It's a field! No need to look in subclasses, fields are not virtual
FieldRef ref = appInfo.getFieldRef(sig);
FieldInfo field = ref.getFieldInfo();
if (field != null) {
markUsedMembers(field);
}
}
}
}
Aggregations