@NodeChildren({@NodeChild(value = "firstNode", type = UnboxNode.class), @NodeChild(value = "secondNode", type = UnboxNode.class)})
abstract static class MaxMinNode extends RootNode {
private final boolean max;
MaxMinNode(boolean max) {
this.max = max;
}
@Specialization
public int execute(int first, int second) {
return max ? Math.max(first, second) : Math.min(first, second);
}
@Specialization
public long execute(long first, long second) {
return max ? Math.max(first, second) : Math.min(first, second);
}
@Specialization
public double execute(double first, double second) {
return max ? Math.max(first, second) : Math.min(first, second);
}
}