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

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

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

import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;

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

abstract class AbstractTerminator extends AbstractNode implements Terminator {
    private final Map targetValues;

    AbstractTerminator(Node callSite, ExecutableElement element, int line, int bci) {
        this(callSite, element, line, bci, Map.of());
    }

    AbstractTerminator(Node callSite, ExecutableElement element, int line, int bci, Map targetValues) {
        super(callSite, element, line, bci);
        targetValues.forEach((s, v) -> {
            if (v == null) {
                throw new IllegalArgumentException("Null value given for slot " + s);
            }
        });
        this.targetValues = targetValues;
    }

    @Override
    public Value getOutboundArgument(Slot slot) throws NoSuchElementException {
        Value value = targetValues.get(slot);
        if (value == null) {
            throw new NoSuchElementException();
        }
        return value;
    }

    @Override
    public Set getOutboundArgumentNames() {
        return targetValues.keySet();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy