package net.sourceforge.javautil.bytecode.api;
import net.sourceforge.javautil.bytecode.api.IBytecodeResolvable.ClassType;
import net.sourceforge.javautil.bytecode.api.type.method.BytecodeContextMethod;
import net.sourceforge.javautil.bytecode.api.type.method.invocation.MethodInvocation;
/**
* The base for most resolvable types.
*
* @author elponderador
* @author $Author$
* @version $Id$
*/
public abstract class BytecodeResolvableAbstract implements IBytecodeResolvable {
protected final ClassType type;
protected final TypeDescriptor descriptor;
public BytecodeResolvableAbstract(ClassType type, TypeDescriptor descriptor) {
this.type = type;
this.descriptor = descriptor;
}
@Override public IBytecodeResolvable getType(BytecodeContextMethod ctx) {
return this;
}
@Override public MethodInvocation createInvocation(BytecodeContextMethod context, String name, IBytecodeReferenceable... parameters) {
return new MethodInvocation(this, this.findMethod(context.getResolutionPool(), name, context.getTypes(parameters)), parameters);
}
@Override public void load(BytecodeContextMethod context) {
context.loadType(this);
}
public ClassType getClassType() { return this.type; }
public TypeDescriptor getType() { return this.descriptor; }
public int compareTo(IBytecodeResolvable o) {
return descriptor.getName().compareTo(o.getType().getName());
}
}