Search in sources :

Example 1 with BooleanConstant

use of org.apache.sling.scripting.sightly.compiler.expression.nodes.BooleanConstant in project sling by apache.

the class DeadCodeRemoval method visit.

@Override
public void visit(VariableBinding.Start variableBindingStart) {
    Boolean truthValue = null;
    ExpressionNode node = variableBindingStart.getExpression();
    if (node instanceof StringConstant) {
        truthValue = CompileTimeObjectModel.toBoolean(((StringConstant) node).getText());
    }
    if (node instanceof BooleanConstant) {
        truthValue = ((BooleanConstant) node).getValue();
    }
    if (node instanceof NumericConstant) {
        truthValue = CompileTimeObjectModel.toBoolean(((NumericConstant) node).getValue());
    }
    if (node instanceof NullLiteral) {
        truthValue = CompileTimeObjectModel.toBoolean(null);
    }
    tracker.pushVariable(variableBindingStart.getVariableName(), truthValue);
    outStream.write(variableBindingStart);
}
Also used : ExpressionNode(org.apache.sling.scripting.sightly.compiler.expression.ExpressionNode) NumericConstant(org.apache.sling.scripting.sightly.compiler.expression.nodes.NumericConstant) BooleanConstant(org.apache.sling.scripting.sightly.compiler.expression.nodes.BooleanConstant) StringConstant(org.apache.sling.scripting.sightly.compiler.expression.nodes.StringConstant) NullLiteral(org.apache.sling.scripting.sightly.compiler.expression.nodes.NullLiteral)

Aggregations

ExpressionNode (org.apache.sling.scripting.sightly.compiler.expression.ExpressionNode)1 BooleanConstant (org.apache.sling.scripting.sightly.compiler.expression.nodes.BooleanConstant)1 NullLiteral (org.apache.sling.scripting.sightly.compiler.expression.nodes.NullLiteral)1 NumericConstant (org.apache.sling.scripting.sightly.compiler.expression.nodes.NumericConstant)1 StringConstant (org.apache.sling.scripting.sightly.compiler.expression.nodes.StringConstant)1