Search in sources :

Example 1 with Descriptor

use of com.jopdesign.common.type.Descriptor in project jop by jop-devel.

the class ClassInfo method createMethod.

/**
     * Create a new non-static, package-visible method with the given name and descriptor.
     *
     * @param memberID the membername and descriptor of the method (classname is ignored).
     * @param argNames the names of the parameters
     * @param code an InstructionList to set to the method as code, or if null, create an abstract method.
     * @return the new method or an existing method with that memberID.
     */
public MethodInfo createMethod(MemberID memberID, String[] argNames, InstructionList code) {
    MethodInfo method = methods.get(memberID.getMethodSignature());
    if (method != null) {
        method.setAbstract(code == null);
        if (code != null) {
            method.getCode().setInstructionList(code);
        }
        return method;
    }
    Descriptor desc = memberID.getDescriptor();
    int flags = (code == null) ? Constants.ACC_ABSTRACT : 0;
    method = new MethodInfo(this, new MethodGen(flags, desc.getType(), desc.getArgumentTypes(), argNames, memberID.getMemberName(), classGen.getClassName(), code, cpg));
    methods.put(memberID.getMethodSignature(), method);
    classGen.addMethod(method.getMethod(false));
    return method;
}
Also used : Descriptor(com.jopdesign.common.type.Descriptor) MethodGen(org.apache.bcel.generic.MethodGen)

Aggregations

Descriptor (com.jopdesign.common.type.Descriptor)1 MethodGen (org.apache.bcel.generic.MethodGen)1