Search in sources :

Example 1 with NodeConditionalDouble

use of buildcraft.lib.expression.node.condition.NodeConditionalDouble in project BuildCraft by BuildCraft.

the class InternalCompiler method pushConditional.

private static void pushConditional(NodeStack stack) throws InvalidExpressionException {
    IExpressionNode right = stack.pop();
    IExpressionNode left = stack.pop();
    IExpressionNode conditional = stack.pop();
    right = convertBinary(right, left);
    left = convertBinary(left, right);
    if (conditional instanceof INodeBoolean) {
        INodeBoolean condition = (INodeBoolean) conditional;
        if (right instanceof INodeBoolean) {
            stack.push(new NodeConditionalBoolean(condition, (INodeBoolean) left, (INodeBoolean) right));
        } else if (right instanceof INodeDouble) {
            stack.push(new NodeConditionalDouble(condition, (INodeDouble) left, (INodeDouble) right));
        } else if (right instanceof INodeObject) {
            stack.push(new NodeConditionalObject(condition, (INodeObject) left, (INodeObject) right));
        } else if (right instanceof INodeLong) {
            stack.push(new NodeConditionalLong(condition, (INodeLong) left, (INodeLong) right));
        } else {
            throw new InvalidExpressionException("Unknown node " + left);
        }
    } else {
        throw new InvalidExpressionException("Required a boolean node, but got '" + conditional + "' of " + conditional.getClass());
    }
}
Also used : NodeConditionalBoolean(buildcraft.lib.expression.node.condition.NodeConditionalBoolean) InvalidExpressionException(buildcraft.lib.expression.api.InvalidExpressionException) INodeDouble(buildcraft.lib.expression.api.IExpressionNode.INodeDouble) NodeConditionalObject(buildcraft.lib.expression.node.condition.NodeConditionalObject) INodeBoolean(buildcraft.lib.expression.api.IExpressionNode.INodeBoolean) INodeLong(buildcraft.lib.expression.api.IExpressionNode.INodeLong) NodeConditionalLong(buildcraft.lib.expression.node.condition.NodeConditionalLong) IExpressionNode(buildcraft.lib.expression.api.IExpressionNode) INodeObject(buildcraft.lib.expression.api.IExpressionNode.INodeObject) NodeConditionalDouble(buildcraft.lib.expression.node.condition.NodeConditionalDouble)

Aggregations

IExpressionNode (buildcraft.lib.expression.api.IExpressionNode)1 INodeBoolean (buildcraft.lib.expression.api.IExpressionNode.INodeBoolean)1 INodeDouble (buildcraft.lib.expression.api.IExpressionNode.INodeDouble)1 INodeLong (buildcraft.lib.expression.api.IExpressionNode.INodeLong)1 INodeObject (buildcraft.lib.expression.api.IExpressionNode.INodeObject)1 InvalidExpressionException (buildcraft.lib.expression.api.InvalidExpressionException)1 NodeConditionalBoolean (buildcraft.lib.expression.node.condition.NodeConditionalBoolean)1 NodeConditionalDouble (buildcraft.lib.expression.node.condition.NodeConditionalDouble)1 NodeConditionalLong (buildcraft.lib.expression.node.condition.NodeConditionalLong)1 NodeConditionalObject (buildcraft.lib.expression.node.condition.NodeConditionalObject)1