use of buildcraft.lib.expression.node.func.NodeFuncGenericToDouble 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());
}
}
Aggregations