Returns the value of the given expression if it's constant, else returns null.
506472
static SoyValue getConstantOrNull(ExprNode expr) {

    switch (expr.getKind()) {
      case NULL_NODE:
        return NullData.INSTANCE;
      case BOOLEAN_NODE:
        return BooleanData.forValue(((BooleanNode) expr).getValue());
      case INTEGER_NODE:
        return IntegerData.forValue(((IntegerNode) expr).getValue());
      case FLOAT_NODE:
        return FloatData.forValue(((FloatNode) expr).getValue());
      case STRING_NODE:
        return StringData.forValue(((StringNode) expr).getValue());
      case GLOBAL_NODE:
        GlobalNode global = (GlobalNode) expr;
        if (global.isResolved()) {
          return getConstantOrNull(global.getValue());
        }
        return null;
      default:
        return null;
    }
  }
1138803
function getValue(ckey, expr) {

    if (ckey !== 'if') {
      var yes = expr in cc.varset ? 1 : 0
      return ckey === 'ifdef' ? yes : yes ^ 1
    }

    // returns the raw value of the expression
    return evalExpr(expr, cc.varset, emitError)
  }
89088
@SuppressWarnings("unchecked")
    public static <T> Expression<T> extract(Expression<T> expr) {
        if (expr != null) {
            final Class<?> clazz = expr.getClass();
            if (clazz == PathImpl.class || clazz == PredicateOperation.class || clazz == ConstantImpl.class) {
                return expr;
            } else {
                return (Expression<T>) expr.accept(ExtractorVisitor.DEFAULT, null);
            }
        } else {
            return null;
        }
    }
1259935
public static Expression constant(@Nullable ContentKind kind) {
    return (kind == null)
        ? BytecodeUtils.constantNull(CONTENT_KIND_TYPE)
        : FieldRef.enumReference(kind).accessor();
  }
893822
private String getBetweenBoundaryValues(Expression boundExpression)
    {
        if (boundExpression instanceof IdentificationVariable || boundExpression instanceof NumericLiteral
                || boundExpression instanceof InputParameter)
        {
            Object value = (boundExpression instanceof InputParameter) ? kunderaQuery.getParametersMap().get(
                    (boundExpression).toParsedText()) : boundExpression.toParsedText();
            return value.toString();
        }
        else if (boundExpression instanceof AdditionExpression)
        {
            String leftValue = checkInputParameter(((AdditionExpression) boundExpression).getLeftExpression());
            String rightValue = checkInputParameter(((AdditionExpression) boundExpression).getRightExpression());

            return new Integer(Integer.parseInt(leftValue) + Integer.parseInt(rightValue)).toString();
        }
        else if (boundExpression instanceof SubtractionExpression)
        {
            String leftValue = checkInputParameter(((SubtractionExpression) boundExpression).getLeftExpression());
            String rightValue = checkInputParameter(((SubtractionExpression) boundExpression).getRightExpression());

            return new Integer(Integer.parseInt(leftValue) - Integer.parseInt(rightValue)).toString();
        }
        else if (boundExpression instanceof MultiplicationExpression)
        {
            String leftValue = checkInputParameter(((MultiplicationExpression) boundExpression).getLeftExpression());
            String rightValue = checkInputParameter(((MultiplicationExpression) boundExpression).getRightExpression());

            return new Integer(Integer.parseInt(leftValue) * Integer.parseInt(rightValue)).toString();
        }

        else if (boundExpression instanceof DivisionExpression)
        {
            String leftValue = checkInputParameter(((DivisionExpression) boundExpression).getLeftExpression());
            String rightValue = checkInputParameter(((DivisionExpression) boundExpression).getRightExpression());
            return new Integer(Integer.parseInt(leftValue) / Integer.parseInt(rightValue)).toString();
        }

        return null;
    }
946923
public static Double checkNull(Double value, double elseValue) {
        return checkNull(value, Double.valueOf(elseValue));
    }
1289291
public static Float checkNull(Float value, float elseValue) {
        return checkNull(value, Float.valueOf(elseValue));
    }
951374
private static ExpressionTree getNullCheckedExpression(ExpressionTree condition) {
    condition = stripParentheses(condition);
    if (!(condition instanceof BinaryTree)) {
      return null;
    }
    BinaryTree bin = (BinaryTree) condition;
    ExpressionTree other;
    if (bin.getLeftOperand().getKind() == Kind.NULL_LITERAL) {
      other = bin.getRightOperand();
    } else if (bin.getRightOperand().getKind() == Kind.NULL_LITERAL) {
      other = bin.getLeftOperand();
    } else {
      return null;
    }
    return other;
  }
657199
@NonNull
    public Expression lessThan(@NonNull Expression expression) {
        if (expression == null) {
            throw new IllegalArgumentException("expression cannot be null.");
        }
        return new BinaryExpression(this, expression, BinaryExpression.OpType.LessThan);
    }
640927
@Override
	public Expression getValueExpression() {
		return ifThenElse(equalTo(count, literal(0L)), nullOf(getResultType()), div(sum, count));
	}
1089653
public static boolean isTrue(Expression expression) {
        if (expression == null) {
            return false;
        }
        if (expression instanceof PropertyExpression
                && classNodeImplementsType(((PropertyExpression) expression).getObjectExpression().getType(), Boolean.class)) {
            if (((PropertyExpression) expression).getProperty() instanceof ConstantExpression
                    && "TRUE".equals(((ConstantExpression) ((PropertyExpression) expression).getProperty()).getValue())) {
                return true;
            }
        }
        return ((expression instanceof ConstantExpression) && ((ConstantExpression) expression).isTrueExpression()) ||
                "Boolean.TRUE".equals(expression.getText());
    }
554622
function getConditional ( parser ) {
  	var start, expression, ifTrue, ifFalse;

  	expression = readLogicalOr$1( parser );
  	if ( !expression ) {
  		return null;
  	}

  	start = parser.pos;

  	parser.allowWhitespace();

  	if ( !parser.matchString( '?' ) ) {
  		parser.pos = start;
  		return expression;
  	}

  	parser.allowWhitespace();

  	ifTrue = readExpression( parser );
  	if ( !ifTrue ) {
  		parser.error( expectedExpression );
  	}

  	parser.allowWhitespace();

  	if ( !parser.matchString( ':' ) ) {
  		parser.error( 'Expected ":"' );
  	}

  	parser.allowWhitespace();

  	ifFalse = readExpression( parser );
  	if ( !ifFalse ) {
  		parser.error( expectedExpression );
  	}

  	return {
  		t: CONDITIONAL,
  		o: [ expression, ifTrue, ifFalse ]
  	};
  }
222985
public void pushConstant(ConstantExpression expression) {
        MethodVisitor mv = controller.getMethodVisitor();
        Object value = expression.getValue();
        ClassNode origType = expression.getType().redirect();
        ClassNode type = ClassHelper.getUnwrapper(origType);
        boolean boxing = origType!=type;
        boolean asPrimitive = boxing || ClassHelper.isPrimitiveType(type);

        if (value == null) {
            mv.visitInsn(ACONST_NULL);
        } else if (boxing && value instanceof Boolean) {
            // special path for boxed boolean
            Boolean bool = (Boolean) value;
            String text = bool ? "TRUE" : "FALSE";
            mv.visitFieldInsn(GETSTATIC, "java/lang/Boolean", text, "Ljava/lang/Boolean;");
            boxing = false;
            type = origType;
        } else if (asPrimitive) {
            pushPrimitiveConstant(mv, value, type);
        } else if (value instanceof BigDecimal) {
            newInstance(mv, value);
        } else if (value instanceof BigInteger) {
            newInstance(mv, value);
        } else if (value instanceof String) {
            mv.visitLdcInsn(value);
        } else {
            throw new ClassGeneratorException(
                    "Cannot generate bytecode for constant: " + value + " of type: " + type.getName());
        }
        
        push(type);
        if (boxing) box(); 
    }
285076
public static <T> T resolveValue(ValueExpression expression, Class<T> type, ELContext elContext) {
		if(expression == null) {
			return null;
		} else {
			return type.cast(expression.getValue(elContext));
		}
	}
561970
def constant(self, val, ty):
        
        if isinstance(val, VexValue) and not isinstance(val, IRExpr):
            raise Exception('Constant cannot be made from VexValue or IRExpr')
        rdt = self.irsb_c.mkconst(val, ty)
        return VexValue(self.irsb_c, rdt)
1001151
public String conditionalExpression() throws RecognitionException {
        int first = input.index();
        exprParser.conditionalExpression();
        if ( state.failed ) return null;

        if ( state.backtracking == 0 && input.index() > first ) {
            // expression consumed something
            String expr = input.toString( first,
                                          input.LT( -1 ).getTokenIndex() );
            return expr;
        }
        return null;
    }
482011
private static boolean valueConstantsMatch(AbstractExpression e1, AbstractExpression e2) {
        return (e1 instanceof ParameterValueExpression && e2 instanceof ConstantValueExpression ||
                e1 instanceof ConstantValueExpression && e2 instanceof ParameterValueExpression) &&
                equalsAsCVE(e1, e2);
    }