getMethod / getField

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@259 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 7080788ef4
commit d55fadbcc6
  1. 25
      jode/jode/decompiler/ClassAnalyzer.java

@ -26,7 +26,7 @@ import jode.bytecode.ConstantPool;
import jode.bytecode.ClassFormatException; import jode.bytecode.ClassFormatException;
import jode.expr.Expression; import jode.expr.Expression;
import jode.flow.TransformConstructors; import jode.flow.TransformConstructors;
import java.util.NoSuchElementException;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
public class ClassAnalyzer implements Analyzer { public class ClassAnalyzer implements Analyzer {
@ -48,17 +48,26 @@ public class ClassAnalyzer implements Analyzer {
this.env = env; this.env = env;
} }
public boolean setFieldInitializer(String fieldName, Type fieldType, public FieldAnalyzer getField(String fieldName, Type fieldType) {
Expression expr) {
for (int i=0; i< fields.length; i++) { for (int i=0; i< fields.length; i++) {
if (fields[i].getName().equals(fieldName) if (fields[i].getName().equals(fieldName)
&& fields[i].getType().isOfType(fieldType)) && fields[i].getType().equals(fieldType))
return fields[i].setInitializer(expr); return fields[i];
} }
System.err.println("Can't find field "+fieldType+" "+fieldName+"."); throw new NoSuchElementException
return false; ("Field "+fieldType+" "+clazz.getName()+"."+fieldName);
} }
public MethodAnalyzer getMethod(String methodName, MethodType methodType) {
for (int i=0; i< methods.length; i++) {
if (methods[i].getName().equals(methodName)
&& methods[i].getType().equals(methodType))
return methods[i];
}
throw new NoSuchElementException
("Method "+methodType+" "+clazz.getName()+"."+methodName);
}
public ClassInfo getClazz() { public ClassInfo getClazz() {
return clazz; return clazz;
} }

Loading…
Cancel
Save