/** * Add a parameter type to this method. */ public void addParam(String type) { String[] origParams = getParamNames(); String[] params = new String[origParams.length + 1]; for (int i = 0; i < origParams.length; i++) params[i] = origParams[i]; params[origParams.length] = type; setParams(params); }
/** * Add a parameter type to this method. */ public void addParam(String type) { String[] origParams = getParamNames(); String[] params = new String[origParams.length + 1]; for (int i = 0; i < origParams.length; i++) params[i] = origParams[i]; params[origParams.length] = type; setParams(params); }
/** * Remove a parameter from this method. */ public void removeParam(int pos) { String[] origParams = getParamNames(); if ((pos < 0) || (pos >= origParams.length)) throw new IndexOutOfBoundsException("pos = " + pos); String[] params = new String[origParams.length - 1]; for (int i = 0, index = 0; i < origParams.length; i++) if (i != pos) params[index++] = origParams[i]; setParams(params); }
/** * Remove a parameter from this method. */ public void removeParam(int pos) { String[] origParams = getParamNames(); if ((pos < 0) || (pos >= origParams.length)) throw new IndexOutOfBoundsException("pos = " + pos); String[] params = new String[origParams.length - 1]; for (int i = 0, index = 0; i < origParams.length; i++) if (i != pos) params[index++] = origParams[i]; setParams(params); }
/** * Removes a method from this class. After this method, the removed method * will be invalid, and the result of any operations on it is undefined. * * @return true if this class contained the method, false otherwise */ public boolean removeDeclaredMethod(BCMethod method) { if (method == null) return false; return removeDeclaredMethod(method.getName(), method.getParamNames()); }
/** * Removes a method from this class. After this method, the removed method * will be invalid, and the result of any operations on it is undefined. * * @return true if this class contained the method, false otherwise */ public boolean removeDeclaredMethod(BCMethod method) { if (method == null) return false; return removeDeclaredMethod(method.getName(), method.getParamNames()); }
/** * Return the {@link Class} objects for all the parameter types for this * method. * * @see BCMember#getDescriptor */ public Class[] getParamTypes() { String[] paramNames = getParamNames(); Class[] params = new Class[paramNames.length]; for (int i = 0; i < paramNames.length; i++) params[i] = Strings.toClass(paramNames[i], getClassLoader()); return params; }
/** * Return the {@link Class} objects for all the parameter types for this * method. * * @see BCMember#getDescriptor */ public Class[] getParamTypes() { String[] paramNames = getParamNames(); Class[] params = new Class[paramNames.length]; for (int i = 0; i < paramNames.length; i++) params[i] = Strings.toClass(paramNames[i], getClassLoader()); return params; }
/** * Return the bytecode for all the parameter types for this method. * * @see BCMember#getDescriptor */ public BCClass[] getParamBCs() { String[] paramNames = getParamNames(); BCClass[] params = new BCClass[paramNames.length]; for (int i = 0; i < paramNames.length; i++) params[i] = getProject().loadClass(paramNames[i], getClassLoader()); return params; }
/** * Return the bytecode for all the parameter types for this method. * * @see BCMember#getDescriptor */ public BCClass[] getParamBCs() { String[] paramNames = getParamNames(); BCClass[] params = new BCClass[paramNames.length]; for (int i = 0; i < paramNames.length; i++) params[i] = getProject().loadClass(paramNames[i], getClassLoader()); return params; }
/** * Set the return type of this method. */ public void setReturn(String name) { setDescriptor(getProject().getNameCache().getDescriptor(name, getParamNames())); }
/** * Set the return type of this method. */ public void setReturn(String name) { setDescriptor(getProject().getNameCache().getDescriptor(name, getParamNames())); }
/** * Set the method this instruction operates on. * * @return this instruction, for method chaining */ public MethodInstruction setMethod(BCMethod method) { if (method == null) return setMethodIndex(0); return setMethod(method.getDeclarer().getName(), method.getName(), method.getReturnName(), method.getParamNames(), false); }
/** * Set the method this instruction operates on. * * @return this instruction, for method chaining */ public MethodInstruction setMethod(BCMethod method) { if (method == null) return setMethodIndex(0); return setMethod(method.getDeclarer().getName(), method.getName(), method.getReturnName(), method.getParamNames(), false); }
/** * Set the method parameter that this instruction operates on. This * will set both the local index and the type of the instruction based * on the current method parameters. */ public LocalVariableInstruction setParam(int param) { int local = getCode().getLocalsIndex(param); if (local != -1) { BCMethod method = getCode().getMethod(); setType(method.getParamNames()[param]); } return setLocal(local); }
/** * Set the method parameter that this instruction operates on. This * will set both the local index and the type of the instruction based * on the current method parameters. */ public LocalVariableInstruction setParam(int param) { int local = getCode().getLocalsIndex(param); if (local != -1) { BCMethod method = getCode().getMethod(); setType(method.getParamNames()[param]); } return setLocal(local); }
/** * Import the information in the given method as a new method of this class. * * @return the added method */ public BCMethod declareMethod(BCMethod method) { BCMethod newMethod = declareMethod(method.getName(), method.getReturnName(), method.getParamNames()); newMethod.setAccessFlags(method.getAccessFlags()); newMethod.setAttributes(method.getAttributes()); return newMethod; }
/** * Import the information in the given method as a new method of this class. * * @return the added method */ public BCMethod declareMethod(BCMethod method) { BCMethod newMethod = declareMethod(method.getName(), method.getReturnName(), method.getParamNames()); newMethod.setAccessFlags(method.getAccessFlags()); newMethod.setAttributes(method.getAttributes()); return newMethod; }
public void enterBCMethod(BCMethod obj) { openBlock("Method"); println("access=" + obj.getAccessFlags()); println("name=" + obj.getNameIndex() + " <" + obj.getName() + ">"); println("descriptor=" + obj.getDescriptorIndex()); println("return=" + obj.getReturnName()); String[] params = obj.getParamNames(); for (int i = 0; i < params.length; i++) println("param=" + params[i]); }
public void enterBCMethod(BCMethod obj) { openBlock("Method"); println("access=" + obj.getAccessFlags()); println("name=" + obj.getNameIndex() + " <" + obj.getName() + ">"); println("descriptor=" + obj.getDescriptorIndex()); println("return=" + obj.getReturnName()); String[] params = obj.getParamNames(); for (int i = 0; i < params.length; i++) println("param=" + params[i]); }