Package org.openquark.cal.internal.machine

Examples of org.openquark.cal.internal.machine.CondTuple


            }
            return gp;
        }

        // Is e a conditional op (if <cond expr> <then expr> <else expr>)?
        CondTuple conditionExpressions = CondTuple.isCondOp(e);
        if (conditionExpressions != null) {
            if (CODEGEN_DIAG) {
                MACHINE_LOGGER.log(Level.FINE, "    condition:");
            }

            // This is a conditional op.  The conditionExpressions tuple holds (kCond, kThen, kElse) expressions
            // Generate the code for kThen and kElse, as arguments to a new I_Cond instruction

            gp.code (schemeE (conditionExpressions.getConditionExpression(), p, d));

            InstructionList thenPart = schemeR (conditionExpressions.getThenExpression(), p, d);
            InstructionList elsePart = schemeR (conditionExpressions.getElseExpression(), p, d);

            Instruction i = new Instruction.I_Cond (new Code (thenPart), new Code(elsePart));

            gp.code (i);
            return gp;         
View Full Code Here


            }
            return gp;
        }

        // Is e a conditional op (if <cond expr> <then expr> <else expr>)?
        CondTuple conditionExpressions = CondTuple.isCondOp(e);
        if (conditionExpressions != null) {
            if (CODEGEN_DIAG) {
                MACHINE_LOGGER.log(Level.FINE, "    condition:");
            }

            // This is a conditional op.  The conditionExpressions tuple holds (kCond, kThen, kElse) expressions
            // Generate the code for kThen and kElse, as arguments to a new I_Cond instruction

            gp.code (schemeE (conditionExpressions.getConditionExpression(), p, d));

            InstructionList thenPart = schemeRS (conditionExpressions.getThenExpression(), p, d, n);
            InstructionList elsePart = schemeRS (conditionExpressions.getElseExpression(), p, d, n);
            if (thenPart == null || elsePart == null) {
                // One of the sub expressions could not be handled by schemeRS.  Return null and
                // let the calling code either abort or use an alternate compilation scheme.
                return null;
            }
View Full Code Here

            }
            return gp;
        }

        // Is e a conditional op (if <cond expr> <then expr> <else expr>)?
        CondTuple conditionExpressions = CondTuple.isCondOp(e);
        if (conditionExpressions != null) {
            if (CODEGEN_DIAG) {
                MACHINE_LOGGER.log(Level.FINE, "    condition:");
            }

            // This is a conditional op.  The conditionExpressions tuple holds (kCond, kThen, kElse) expressions
            // Generate the code for kThen and kElse, as arguments to a new I_Cond instruction

            gp.code (schemeE (conditionExpressions.getConditionExpression(), p, d));

            InstructionList thenPart = schemeE (conditionExpressions.getThenExpression(), p, d);
            InstructionList elsePart = schemeE (conditionExpressions.getElseExpression(), p, d);

            Instruction i = new Instruction.I_Cond (new Code (thenPart), new Code(elsePart));

            gp.code (i);
            return gp;         
View Full Code Here

            }
            return gp;
        }

        // Is e a conditional op (if <cond expr> <then expr> <else expr>)?
        CondTuple conditionExpressions = CondTuple.isCondOp(e);
        if (conditionExpressions != null) {
            if (CODEGEN_DIAG) {
                MACHINE_LOGGER.log(Level.FINE, "    condition:");
            }

            // This is a conditional op.  The conditionExpressions tuple holds (kCond, kThen, kElse) expressions
            // Generate the code for kThen and kElse, as arguments to a new I_Cond instruction

            gp.code (schemeE (conditionExpressions.getConditionExpression(), p, d));

            InstructionList thenPart = schemeES (conditionExpressions.getThenExpression(), p, d, n);
            InstructionList elsePart = schemeES (conditionExpressions.getElseExpression(), p, d, n);
            if (thenPart == null || elsePart == null) {
                // Either the then or else part could not be handled by the RS scheme. Return null and
                // let the calling code decide whether to abort or use an alternate scheme.
                return null;
            }
View Full Code Here

                return true;
            }
        }

        // 'if a then b else c' where laziness can be ignore for a, b, and c.
        CondTuple conditionExpressions = CondTuple.isCondOp(e);
        if (conditionExpressions != null) {
            Expression condExpr = conditionExpressions.getConditionExpression();
            Expression thenExpr = conditionExpressions.getThenExpression();
            Expression elseExpr = conditionExpressions.getElseExpression();
            if (canIgnoreLaziness(condExpr, env) &&
                    canIgnoreLaziness(thenExpr, env) &&
                    canIgnoreLaziness(elseExpr, env)) {
                return true;
            }
View Full Code Here

                return true;
            }
        }

        // 'if a then b else c' where a, b, and c can all be shortcut.
        CondTuple conditionExpressions = CondTuple.isCondOp(e);
        if (conditionExpressions != null) {
            Expression condExpr = conditionExpressions.getConditionExpression();
            Expression thenExpr = conditionExpressions.getThenExpression();
            Expression elseExpr = conditionExpressions.getElseExpression();
            if (canIgnoreLaziness(condExpr, variableContext) &&
                canIgnoreLaziness(thenExpr, variableContext) &&
                canIgnoreLaziness(elseExpr, variableContext)) {
                return true;
            }
View Full Code Here

                }
            }
        }

        // Is e a conditional op (if <cond expr> <then expr> <else expr>)?
        CondTuple conditionExpressions = CondTuple.isCondOp(e);
        if (conditionExpressions != null) {
            if (codeGenerationStats != null) {
                codeGenerationStats.incrementOptimizedIfThenElse();
            }

            // This is a conditional op.  The conditionExpressions tuple holds (kCond, kThen, kElse) expressions
            // Generate the code for kThen and kElse, as arguments to a new I_Cond instruction

            Expression condExpression = conditionExpressions.getConditionExpression();
            ExpressionContextPair pair;
            pair = generateUnboxedArgument(JavaTypeName.BOOLEAN, condExpression, variableContext);

            Block contextBlock = pair.getContextBlock();
            JavaExpression condJavaExpression = pair.getJavaExpression();
            ExpressionContextPair thenPart = genS_E (conditionExpressions.getThenExpression(), variableContext);
            ExpressionContextPair elsePart = genS_E (conditionExpressions.getElseExpression(), variableContext);

            // Note: both contexts are evaluated..
            contextBlock.addStatement(thenPart.getContextBlock());
            contextBlock.addStatement(elsePart.getContextBlock());
View Full Code Here

            return generateReturn(varExpression, variableContext);
        }

        // Is e a conditional op (if <cond expr> <then expr> <else expr>)?
        // Since this is the top level compilation scheme we can generate an actual 'if' statement.
        CondTuple conditionExpressions = CondTuple.isCondOp(e);
        if (conditionExpressions != null) {
            if (codeGenerationStats != null) {
                codeGenerationStats.incrementOptimizedIfThenElse();
            }

            // This is a conditional op.  The conditionExpressions tuple holds (kCond, kThen, kElse) expressions
            // Generate the code for kThen and kElse, as arguments to a new I_Cond instruction

            Expression condExpression = conditionExpressions.getConditionExpression();
            ExpressionContextPair pair = generateUnboxedArgument(JavaTypeName.BOOLEAN, condExpression, variableContext);

            // Then
            variableContext.pushJavaScope();
            JavaStatement thenPart = genS_R (conditionExpressions.getThenExpression(), variableContext);

            Block thenBlock = variableContext.popJavaScope();
            thenBlock.addStatement(thenPart);

            // Else
            variableContext.pushJavaScope();
            JavaStatement elsePart = genS_R (conditionExpressions.getElseExpression(), variableContext);

            Block elseBlock = variableContext.popJavaScope();
            elseBlock.addStatement(elsePart);

            JavaExpression conditionExpression = pair.getJavaExpression();
View Full Code Here

TOP

Related Classes of org.openquark.cal.internal.machine.CondTuple

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.