package accrue;

import java.util.Collections;

import polyglot.types.CodeInstance;
import polyglot.types.MethodInstance;
import polyglot.types.Type;

public class AccrueUtil {
    public static boolean isMainMethod(CodeInstance pi) {
        if (pi instanceof MethodInstance) {
            MethodInstance mi = (MethodInstance) pi;
            if (mi.name().equals("main") && mi.flags().isStatic()
                    && mi.flags().isPublic() && mi.returnType().isVoid()) {
                Type stringArr =
                        pi.typeSystem().arrayOf(pi.typeSystem().String());
                return mi.formalTypes()
                         .equals(Collections.singletonList(stringArr));
            }
        }
        return false;
    }

}
