Package com.facebook.presto.byteCode.control

Examples of com.facebook.presto.byteCode.control.IfStatement$IfStatementBuilder


            if (javaType == boolean.class) {
                Block isNotNull = new Block(context)
                        .getVariable("cursor")
                        .push(channel)
                        .invokeInterface(RecordCursor.class, "getBoolean", boolean.class, int.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else if (javaType == long.class) {
                Block isNotNull = new Block(context)
                        .getVariable("cursor")
                        .push(channel)
                        .invokeInterface(RecordCursor.class, "getLong", long.class, int.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else if (javaType == double.class) {
                Block isNotNull = new Block(context)
                        .getVariable("cursor")
                        .push(channel)
                        .invokeInterface(RecordCursor.class, "getDouble", double.class, int.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else if (javaType == Slice.class) {
                Block isNotNull = new Block(context)
                        .getVariable("cursor")
                        .push(channel)
                        .invokeInterface(RecordCursor.class, "getSlice", Slice.class, int.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else {
                throw new UnsupportedOperationException("not yet implemented: " + type);
            }
        }
        else {
            Block isNullCheck = new Block(context)
                    .setDescription(format("block_%d.get%s()", channel, type))
                    .getVariable("block_" + channel)
                    .getVariable("position")
                    .invokeInterface(com.facebook.presto.spi.block.Block.class, "isNull", boolean.class, int.class);

            Block isNull = new Block(context)
                    .putVariable("wasNull", true)
                    .pushJavaDefault(javaType);
            if (javaType == boolean.class) {
                Block isNotNull = new Block(context)
                        .getVariable("block_" + channel)
                        .getVariable("position")
                        .invokeInterface(com.facebook.presto.spi.block.Block.class, "getBoolean", boolean.class, int.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else if (javaType == long.class) {
                Block isNotNull = new Block(context)
                        .getVariable("block_" + channel)
                        .getVariable("position")
                        .invokeInterface(com.facebook.presto.spi.block.Block.class, "getLong", long.class, int.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else if (javaType == double.class) {
                Block isNotNull = new Block(context)
                        .getVariable("block_" + channel)
                        .getVariable("position")
                        .invokeInterface(com.facebook.presto.spi.block.Block.class, "getDouble", double.class, int.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else if (javaType == Slice.class) {
                Block isNotNull = new Block(context)
                        .getVariable("block_" + channel)
                        .getVariable("position")
                        .invokeInterface(com.facebook.presto.spi.block.Block.class, "getSlice", Slice.class, int.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else {
                throw new UnsupportedOperationException("not yet implemented: " + type);
            }
        }
View Full Code Here


        Block block = new Block(context)
                .comment(node.toString())
                .comment("left")
                .append(process(node.getLeft(), context))
                .append(new IfStatement(context,
                        new Block(context).getVariable("wasNull"),
                        new Block(context)
                                .pop(leftType.getJavaType())
                                .putVariable("wasNull", false)
                                .comment("right is not null")
                                .append(process(node.getRight(), context))
                                .pop(rightType.getJavaType())
                                .getVariable("wasNull")
                                .invokeStatic(CompilerOperations.class, "not", boolean.class, boolean.class),
                        new Block(context)
                                .comment("right")
                                .append(process(node.getRight(), context))
                                .append(new IfStatement(context,
                                        new Block(context).getVariable("wasNull"),
                                        new Block(context)
                                                .pop(leftType.getJavaType())
                                                .pop(rightType.getJavaType())
                                                .push(true),
View Full Code Here

                    .getVariable("wasNull")
                    .invokeStatic(CompilerOperations.class, "not", boolean.class, boolean.class)
                    .invokeStatic(CompilerOperations.class, "and", boolean.class, boolean.class, boolean.class)
                    .putVariable("wasNull", false);

            elseValue = new IfStatement(context, condition, whenClause.valueBlock, elseValue);
        }

        return elseValue;
    }
View Full Code Here

            Block condition = new Block(context)
                    .append(equalsCall)
                    .putVariable("wasNull", false);

            elseValue = new IfStatement(context,
                    format("when %s", whenClause.operand),
                    condition,
                    whenClause.valueBlock,
                    elseValue);
        }
View Full Code Here

                .putVariable("wasNull", true)
                .pop(firstType.getJavaType())
                .pushJavaDefault(firstType.getJavaType());

        // else return first (which is still on the stack
        block.append(new IfStatement(context, conditionBlock, trueBlock, notMatch));

        return block;
    }
View Full Code Here

            Block nullBlock = new Block(context)
                    .pop(type)
                    .putVariable("wasNull", false)
                    .append(nullValue);

            nullValue = new IfStatement(context, condition, nullBlock, NOP);
        }

        return nullValue;
    }
View Full Code Here

                    ImmutableList.<ByteCodeNode>of(),
                    new InFunctionBinder(javaType, constantValues));

            switchBlock = new Block(context)
                    .comment("inListSet.contains(<stackValue>)")
                    .append(new IfStatement(context,
                            new Block(context).dup(javaType).invokeDynamic(functionBinding.getName(), functionBinding.getCallSite().type(), functionBinding.getBindingId()),
                            jump(match),
                            NOP));
        }
View Full Code Here

            if (javaType == boolean.class) {
                Block isNotNull = new Block(context)
                        .getVariable("cursor")
                        .push(channel)
                        .invokeInterface(RecordCursor.class, "getBoolean", boolean.class, int.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else if (javaType == long.class) {
                Block isNotNull = new Block(context)
                        .getVariable("cursor")
                        .push(channel)
                        .invokeInterface(RecordCursor.class, "getLong", long.class, int.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else if (javaType == double.class) {
                Block isNotNull = new Block(context)
                        .getVariable("cursor")
                        .push(channel)
                        .invokeInterface(RecordCursor.class, "getDouble", double.class, int.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else if (javaType == Slice.class) {
                Block isNotNull = new Block(context)
                        .getVariable("cursor")
                        .push(channel)
                        .invokeInterface(RecordCursor.class, "getSlice", Slice.class, int.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else {
                throw new UnsupportedOperationException("not yet implemented: " + type);
            }
        }
        else {
            Block isNullCheck = new Block(context)
                    .setDescription(format("channel_%d.get%s()", channel, type))
                    .getVariable("channel_" + channel)
                    .invokeInterface(BlockCursor.class, "isNull", boolean.class);

            Block isNull = new Block(context)
                    .putVariable("wasNull", true)
                    .pushJavaDefault(javaType);
            if (javaType == boolean.class) {
                Block isNotNull = new Block(context)
                        .getVariable("channel_" + channel)
                        .invokeInterface(BlockCursor.class, "getBoolean", boolean.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else if (javaType == long.class) {
                Block isNotNull = new Block(context)
                        .getVariable("channel_" + channel)
                        .invokeInterface(BlockCursor.class, "getLong", long.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else if (javaType == double.class) {
                Block isNotNull = new Block(context)
                        .getVariable("channel_" + channel)
                        .invokeInterface(BlockCursor.class, "getDouble", double.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else if (javaType == Slice.class) {
                Block isNotNull = new Block(context)
                        .getVariable("channel_" + channel)
                        .invokeInterface(BlockCursor.class, "getSlice", Slice.class);
                return new IfStatement(context, isNullCheck, isNull, isNotNull);
            }
            else {
                throw new UnsupportedOperationException("not yet implemented: " + type);
            }
        }
View Full Code Here

        Block block = new Block(context)
                .comment(node.toString())
                .comment("left")
                .append(process(node.getLeft(), context))
                .append(new IfStatement(context,
                        new Block(context).getVariable("wasNull"),
                        new Block(context)
                                .pop(leftType.getJavaType())
                                .putVariable("wasNull", false)
                                .comment("right is not null")
                                .append(process(node.getRight(), context))
                                .pop(rightType.getJavaType())
                                .getVariable("wasNull")
                                .invokeStatic(CompilerOperations.class, "not", boolean.class, boolean.class),
                        new Block(context)
                                .comment("right")
                                .append(process(node.getRight(), context))
                                .append(new IfStatement(context,
                                        new Block(context).getVariable("wasNull"),
                                        new Block(context)
                                                .pop(leftType.getJavaType())
                                                .pop(rightType.getJavaType())
                                                .push(true),
View Full Code Here

                    .getVariable("wasNull")
                    .invokeStatic(CompilerOperations.class, "not", boolean.class, boolean.class)
                    .invokeStatic(CompilerOperations.class, "and", boolean.class, boolean.class, boolean.class)
                    .putVariable("wasNull", false);

            elseValue = new IfStatement(context, condition, whenClause.valueBlock, elseValue);
        }

        return elseValue;
    }
View Full Code Here

TOP

Related Classes of com.facebook.presto.byteCode.control.IfStatement$IfStatementBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.