Search in sources :

Example 1 with Operator

use of com.google.template.soy.exprtree.Operator in project closure-templates by google.

the class TranslateToPyExprVisitor method visitConditionalOpNode.

@Override
protected PyExpr visitConditionalOpNode(ConditionalOpNode node) {
    // Retrieve the operands.
    Operator op = Operator.CONDITIONAL;
    List<SyntaxElement> syntax = op.getSyntax();
    List<PyExpr> operandExprs = visitChildren(node);
    Operand conditionalOperand = ((Operand) syntax.get(0));
    PyExpr conditionalExpr = operandExprs.get(conditionalOperand.getIndex());
    Operand trueOperand = ((Operand) syntax.get(4));
    PyExpr trueExpr = operandExprs.get(trueOperand.getIndex());
    Operand falseOperand = ((Operand) syntax.get(8));
    PyExpr falseExpr = operandExprs.get(falseOperand.getIndex());
    return genTernaryConditional(conditionalExpr, trueExpr, falseExpr);
}
Also used : Operator(com.google.template.soy.exprtree.Operator) PyExpr(com.google.template.soy.pysrc.restricted.PyExpr) Operand(com.google.template.soy.exprtree.Operator.Operand) SyntaxElement(com.google.template.soy.exprtree.Operator.SyntaxElement)

Aggregations

Operator (com.google.template.soy.exprtree.Operator)1 Operand (com.google.template.soy.exprtree.Operator.Operand)1 SyntaxElement (com.google.template.soy.exprtree.Operator.SyntaxElement)1 PyExpr (com.google.template.soy.pysrc.restricted.PyExpr)1