Examples of CalcProgramBuilder


Examples of net.sf.farrago.fennel.calc.CalcProgramBuilder

            CalcReg accumulatorRegister,
            RexToCalcTranslator translator)
        {
            assert call.operands.length == 1;
            final RexNode operand = call.operands[0];
            final CalcProgramBuilder builder = translator.builder;
            CalcReg input = translator.implementNode(operand);
            CalcReg tempBoolReg = translator.getTempBoolRegister();

            //check operand for null if it is nullable
            String noReplaceLabel = translator.newLabel();
            ;
            String doReplaceLabel = translator.newLabel();
            if (operand.getType().isNullable()) {
                CalcProgramBuilder.boolNativeIsNull.add(
                    translator.builder,
                    tempBoolReg,
                    input);
                builder.addLabelJumpTrue(noReplaceLabel, tempBoolReg);
                CalcProgramBuilder.boolNativeIsNull.add(
                    translator.builder,
                    tempBoolReg,
                    accumulatorRegister);
                builder.addLabelJumpTrue(doReplaceLabel, tempBoolReg);
            }
            InstructionDef compareInstruction =
                isMin() ? CalcProgramBuilder.boolLessThan
                : CalcProgramBuilder.boolGreaterThan;
            if (SqlTypeUtil.inCharFamily(operand.getType())) {
                final CalcReg tempInt4 = translator.getTempInt4Register();
                final CalcReg zeroReg = translator.builder.newInt4Literal(0);
                ExtInstructionDefTable.strCmpA.add(
                    builder,
                    tempInt4,
                    translator.implementNode(operand),
                    accumulatorRegister);
                compareInstruction.add(
                    builder,
                    tempBoolReg,
                    tempInt4,
                    zeroReg);
            } else {
                compareInstruction.add(
                    builder,
                    tempBoolReg,
                    translator.implementNode(operand),
                    accumulatorRegister);
            }
            builder.addLabelJumpFalse(noReplaceLabel, tempBoolReg);

            builder.addLabel(doReplaceLabel);

            // Use ref instead of move since could be replacing a null
            CalcProgramBuilder.refInstruction.add(
                translator.builder,
                accumulatorRegister,
                input);
            builder.addLabel(noReplaceLabel);
        }
View Full Code Here

Examples of net.sf.farrago.fennel.calc.CalcProgramBuilder

        private static CalcReg implementTimeFunc(
            CalcProgramBuilder.ExtInstrDef instruction,
            RexNode operand,
            RexToCalcTranslator translator)
        {
            final CalcProgramBuilder progBuilder = translator.builder;
            List<CalcReg> regList = new ArrayList<CalcReg>();

            CalcReg timeReg =
                progBuilder.newLocal(CalcProgramBuilder.OpType.Int8, -1);

            // Call will be to store time func result in local reg with
            // optional precision operand.
            regList.add(timeReg);

            // The LocalTimestamp and LocalTime instructions take the POSIX
            // description of the timezone (e.g. "PST-8PDT,M4.1.0,M10.1.0")
            // as an implicit first argument.
            //
            // Timezone is inherited from the JVM.
            // You can override using '-Duser.timezone=...".
            if (instruction.name.startsWith("Local")) {
                String tzDesc = Util.toPosix(TimeZone.getDefault(), false);
                regList.add(
                    translator.implementNode(
                        translator.rexBuilder.makeLiteral(tzDesc)));
            }

            if (operand != null) {
                regList.add(translator.implementNode(operand));
            }

            String notZeroLabel = translator.newLabel();

            CalcReg isNotZeroReg =
                progBuilder.newLocal(CalcProgramBuilder.OpType.Bool, -1);

            CalcReg zeroReg = progBuilder.newInt8Literal(0);

            CalcProgramBuilder.boolNativeNotEqual.add(
                progBuilder,
                isNotZeroReg,
                timeReg,
                zeroReg);

            progBuilder.addLabelJumpTrue(notZeroLabel, isNotZeroReg);

            // store time func result in local reg
            instruction.add(progBuilder, regList);

            // dangling label on whatever comes next
            progBuilder.addLabel(notZeroLabel);

            return timeReg;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.