src/filter_tree/filter_tree.c
// Compacts a predicate node if possible,
Compacts a predicate node if possible.
Compacts a predicate node if possible .
static bool _FilterTree_Compact_Pred(FT_FilterNode *node) {
	if((AR_EXP_IsConstant(node->pred.lhs) || AR_EXP_IsParameter(node->pred.lhs)) &&
	   (AR_EXP_IsConstant(node->pred.rhs) || AR_EXP_IsParameter(node->pred.rhs))) {
		SIValue lhs = AR_EXP_Evaluate(node->pred.lhs, NULL);
		SIValue rhs = AR_EXP_Evaluate(node->pred.rhs, NULL);
		int ret = _applyFilter(&lhs, &rhs, node->pred.op);
		SIValue v = SI_BoolVal(ret);
		AR_EXP_Free(node->pred.lhs);
		AR_EXP_Free(node->pred.rhs);
		_FilterTree_In_Place_Set_Exp(node, v);
		return true;
	}
	return false;
}
static bool _FilterTree_Compact_Pred ( FT_FilterNode * node ) { if ( ( AR_EXP_IsConstant ( node -> pred . lhs ) || AR_EXP_IsParameter ( node -> pred . lhs ) ) && ( AR_EXP_IsConstant ( node -> pred . rhs ) || AR_EXP_IsParameter ( node -> pred . rhs ) ) ) { SIValue lhs = AR_EXP_Evaluate ( node -> pred . lhs , NULL ) ; SIValue rhs = AR_EXP_Evaluate ( node -> pred . rhs , NULL ) ; int ret = _applyFilter ( & lhs , & rhs , node -> pred . op ) ; SIValue v = SI_BoolVal ( ret ) ; AR_EXP_Free ( node -> pred . lhs ) ; AR_EXP_Free ( node -> pred . rhs ) ; _FilterTree_In_Place_Set_Exp ( node , v ) ; return true ; } return false ; }
Compacts a predicate node if possible,
Compacts a predicate node if possible
// Check both sides are constant expressions. // Evaluate expressions. // Evalute result. // Free resources and do in place replacment.