use of com.jopdesign.common.ClassInfo 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.ClassInfo in project jop by jop-devel.
the class LinkerInfo method getOrCreateLinkInfo.
private LinkInfo getOrCreateLinkInfo(String classname) throws ClassNotFoundException {
ClassInfo klass = project.getAppInfo().getClassInfo(classname);
if (klass == null)
throw new ClassNotFoundException(classname);
LinkInfo linkInfo = classLinkInfo.get(classname);
if (linkInfo == null) {
linkInfo = new LinkInfo(klass, 0, 0);
classLinkInfo.put(classname, linkInfo);
}
return linkInfo;
}
use of com.jopdesign.common.ClassInfo in project jop by jop-devel.
the class InvokeSite method isSuperMethod.
/**
* Check if this invokespecial is a super invoke. Does NOT check if the instruction is indeed an
* special invoke, check this first!
* See #isInvokeSuper() for more details.
*
* @param invokee the method referenced by the instruction.
* @return true if this references to a super method
*/
private boolean isSuperMethod(MethodRef invokee) {
// This is the class where the invoker method is defined (not the class of the object instance!)
ClassInfo cls = invoker.getClassInfo();
if (!cls.hasSuperFlag())
return false;
if ("<init>".equals(invokee.getName()))
return false;
// just to handle some special cases of unknown superclasses gracefully, without requiring a classInfo
if (cls.getClassName().equals(invokee.getClassName())) {
// this is an invoke within the same class, no super here
return false;
}
if (cls.isRootClass()) {
// trying to call a super-method of Object? Not likely, dude ..
return false;
}
// do not need to check interfaces, since invokespecial must not call interface methods
Ternary rs = cls.hasSuperClass(invokee.getClassName(), false);
if (rs == Ternary.UNKNOWN) {
if (invokee.getClassRef().getClassInfo() != null) {
// class exists, but method does not exists, either an error or superclasses are missing
throw new JavaClassFormatError("Invokespecial tries to call " + invokee + " but this method has not been found");
}
// invokespecial to an unknown class, we cannot handle this safely
throw new JavaClassFormatError("Could not determine if invokespecial is a super invoke for " + invokee);
}
return rs == Ternary.TRUE;
}
use of com.jopdesign.common.ClassInfo in project jop by jop-devel.
the class BasicBlock method getStartLine.
/**
* @return a human readable string representation of the location of the first instruction
* in the basic block
*/
public String getStartLine() {
ClassInfo cls = null;
int line = -1;
for (InstructionHandle ih : instructions) {
cls = methodCode.getSourceClassInfo(ih);
line = methodCode.getLineNumber(this.getFirstInstruction());
if (line >= 0)
break;
}
if (line >= 0) {
return cls.getSourceFileName() + ":" + line;
} else {
return getMethodInfo().getClassInfo().getSourceFileName() + ":" + getMethodInfo().getFQMethodName();
}
}
use of com.jopdesign.common.ClassInfo in project jop by jop-devel.
the class BasicBlock method getSourceLines.
/**
* @return all source code lines this basic block maps to
*/
public Map<ClassInfo, TreeSet<Integer>> getSourceLines() {
Map<ClassInfo, TreeSet<Integer>> map = new HashMap<ClassInfo, TreeSet<Integer>>(2);
for (InstructionHandle ih : instructions) {
ClassInfo cls = methodCode.getSourceClassInfo(ih);
TreeSet<Integer> lines = map.get(cls);
if (lines == null) {
lines = new TreeSet<Integer>();
map.put(cls, lines);
}
int line = methodCode.getLineNumber(ih);
if (line >= 0)
lines.add(line);
}
return map;
}
Aggregations