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

org.qbicc.graph.Call Maven / Gradle / Ivy

There is a newer version: 0.77.0
Show newest version
package org.qbicc.graph;

import java.util.List;
import java.util.Objects;

import org.qbicc.type.ValueType;
import org.qbicc.type.definition.element.ExecutableElement;

/**
 * A plain method or function call.
 * The return value of the target is the type of this node (which may be {@link org.qbicc.type.VoidType VoidType}).
 * Exceptions thrown by the target are not caught; instead, they are propagated out of the caller's frame.
 *
 * @see BasicBlockBuilder#call(org.qbicc.graph.Value, org.qbicc.graph.Value, java.util.List)
 */
public final class Call extends AbstractValue implements OrderedNode, InvocationNode {
    private final Node dependency;
    private final Value target;
    private final Value receiver;
    private final List arguments;

    Call(Node callSite, ExecutableElement element, int line, int bci, Node dependency, Value target, Value receiver, List arguments) {
        super(callSite, element, line, bci);
        this.dependency = dependency;
        this.target = target;
        this.receiver = receiver;
        this.arguments = arguments;
    }

    @Override
    int calcHashCode() {
        return Objects.hash(Call.class, dependency, target, receiver, arguments);
    }

    @Override
    String getNodeName() {
        return "Call";
    }

    @Override
    public boolean equals(Object other) {
        return other instanceof Call && equals((Call) other);
    }

    public boolean equals(Call other) {
        return this == other || other != null && dependency.equals(other.dependency) && target.equals(other.target) && receiver.equals(other.receiver) && arguments.equals(other.arguments);
    }

    @Override
    StringBuilder toRValueString(StringBuilder b) {
        return InvocationNode.toRValueString(this, "call", b);
    }

    @Override
    public Node getDependency() {
        return dependency;
    }

    @Override
    public boolean maySafePoint() {
        return ! target.isNoSafePoints();
    }

    @Override
    public Value getTarget() {
        return target;
    }

    @Override
    public Value getReceiver() {
        return receiver;
    }

    @Override
    public ValueType getType() {
        return getCalleeType().getReturnType();
    }

    public List getArguments() {
        return arguments;
    }

    @Override
    public  R accept(ValueVisitor visitor, T param) {
        return visitor.visit(param, this);
    }

    public boolean isConstant() {
        return false;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy