All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.andyshao.asm.ClassVisitorOperation Maven / Gradle / Ivy

The newest version!
package com.github.andyshao.asm;

import java.lang.reflect.Method;

/**
 * 
 * Title:
* Descript:
* Copyright: Copryright(c) Apr 20, 2016
* Encoding:UNIX UTF-8 * * @author Andy.Shao * */ public final class ClassVisitorOperation { /** * count basic local * @param method {@link Method} * @return the number of basic local */ public static final int countBasicLocal(Method method) { int result = method.getParameterCount() + 1; Class[] types = method.getParameterTypes(); for (Class parameter : types) if (long.class.isAssignableFrom(parameter) || double.class.isAssignableFrom(parameter)) result++; return result; } /** * count basic stack * @param method {@link Method} * @return the number of basic stack */ public static final int countBasicStack(Method method) { Class type = method.getReturnType(); if (type.isPrimitive()) { if (long.class.isAssignableFrom(type) || double.class.isAssignableFrom(type)) return 2; else if (void.class.isAssignableFrom(type)) return 0; else return 1; } else return 1; } private ClassVisitorOperation() { throw new AssertionError("No " + ClassVisitorOperation.class + " instance for you"); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy