Search in sources :

Example 1 with NodeFuncGenericToLong

use of buildcraft.lib.expression.node.func.NodeFuncGenericToLong in project BuildCraft by BuildCraft.

the class InternalCompiler method compileFunction.

public static INodeFunc compileFunction(String expression, FunctionContext context, Argument... args) throws InvalidExpressionException {
    FunctionContext ctxReal = new FunctionContext(context);
    IVariableNode[] nodes = new IVariableNode[args.length];
    Class<?>[] types = new Class[args.length];
    for (int i = 0; i < nodes.length; i++) {
        types[i] = args[i].type;
        nodes[i] = ctxReal.putVariable(args[i].name, args[i].type);
    }
    IExpressionNode node = compileExpression(expression, ctxReal);
    if (node instanceof INodeLong) {
        return new NodeFuncGenericToLong((INodeLong) node, types, nodes);
    } else if (node instanceof INodeDouble) {
        return new NodeFuncGenericToDouble((INodeDouble) node, types, nodes);
    } else if (node instanceof INodeBoolean) {
        return new NodeFuncGenericToBoolean((INodeBoolean) node, types, nodes);
    } else if (node instanceof INodeObject<?>) {
        return new NodeFuncGenericToObject<>((INodeObject<?>) node, types, nodes);
    } else {
        ExpressionDebugManager.debugNodeClass(node.getClass());
        throw new IllegalStateException("Unknown node " + node.getClass());
    }
}
Also used : NodeFuncGenericToLong(buildcraft.lib.expression.node.func.NodeFuncGenericToLong) NodeFuncGenericToDouble(buildcraft.lib.expression.node.func.NodeFuncGenericToDouble) INodeBoolean(buildcraft.lib.expression.api.IExpressionNode.INodeBoolean) IVariableNode(buildcraft.lib.expression.api.IVariableNode) INodeLong(buildcraft.lib.expression.api.IExpressionNode.INodeLong) NodeFuncGenericToBoolean(buildcraft.lib.expression.node.func.NodeFuncGenericToBoolean) INodeDouble(buildcraft.lib.expression.api.IExpressionNode.INodeDouble) IExpressionNode(buildcraft.lib.expression.api.IExpressionNode) INodeObject(buildcraft.lib.expression.api.IExpressionNode.INodeObject)

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 IVariableNode (buildcraft.lib.expression.api.IVariableNode)1 NodeFuncGenericToBoolean (buildcraft.lib.expression.node.func.NodeFuncGenericToBoolean)1 NodeFuncGenericToDouble (buildcraft.lib.expression.node.func.NodeFuncGenericToDouble)1 NodeFuncGenericToLong (buildcraft.lib.expression.node.func.NodeFuncGenericToLong)1