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

soot.jimple.JMethodType Maven / Gradle / Ivy

/* Soot - a J*va Optimization Framework
 * Copyright (C) 2014 RoboVM AB
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */
package soot.jimple;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import soot.RefType;
import soot.SootMethodType;
import soot.Type;
import soot.util.Switch;

/**
 * {@link SootMethodType} implementation.
 * RoboVM note: Added in RoboVM.
 */
class JMethodType extends Constant implements SootMethodType {
    private static final long serialVersionUID = 1L;

    private final Type returnType;
    private final List parameterTypes;

    public JMethodType(Type returnType, List parameterTypes) {
        this.returnType = returnType;
        this.parameterTypes = parameterTypes;
    }

    public Type getReturnType() {
        return returnType;
    }
    
    public List getParameterTypes() {
        return Collections.unmodifiableList(parameterTypes);
    }

    @Override
    public Type getType() {
        return RefType.v("java.lang.invoke.MethodType");
    }

    @Override
    public void apply(Switch sw) {
        ((ConstantSwitch) sw).defaultCase(this);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();

        sb.append('(');
        for (Iterator it = parameterTypes.iterator(); it.hasNext();) {
            sb.append(it.next());
            if (it.hasNext()) {
                sb.append(',');
            }
        }
        return sb.append(')').append(returnType).toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy