/**
 * 
 */
package de.dhbwstuttgart.bytecode.utilities;

import java.util.Iterator;

import de.dhbwstuttgart.syntaxtree.FormalParameter;
import de.dhbwstuttgart.syntaxtree.Method;

/**
 * @author fayez
 *
 */
public class MethodUtility {
	/**
	 * Creates an ID for a method
	 * 
	 * @param resolver type Resolver
	 * @param method   for which the ID will be generated
	 * @return ID for the given method. 
	 * 	ID = ReturntypeMethodname(Parametertypes)
	 */
	public static String createID(Resolver resolver, Method method) {
		String id = resolver.getResolvedType(method.getReturnType()) + method.name + "(";
		Iterator<FormalParameter> itr = method.getParameterList().iterator();
		while (itr.hasNext()) {
			FormalParameter fp = itr.next();
			id += resolver.getResolvedType(fp.getType());
		}
		id += ")";
		return id;
	}
}
